Add project files.
This commit is contained in:
44
Library/WinAPI/Blur.cs
Normal file
44
Library/WinAPI/Blur.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CMM.Library.WinAPI
|
||||
{
|
||||
#region 透明背景
|
||||
public enum AccentState
|
||||
{
|
||||
ACCENT_DISABLED = 0,
|
||||
ACCENT_ENABLE_GRADIENT = 1,
|
||||
ACCENT_ENABLE_TRANSPARENTGRADIENT = 2,
|
||||
ACCENT_ENABLE_BLURBEHIND = 3,
|
||||
ACCENT_INVALID_STATE = 4
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct AccentPolicy
|
||||
{
|
||||
public AccentState AccentState;
|
||||
public int AccentFlags;
|
||||
public int GradientColor;
|
||||
public int AnimationId;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct WindowCompositionAttributeData
|
||||
{
|
||||
public WindowCompositionAttribute Attribute;
|
||||
public IntPtr Data;
|
||||
public int SizeOfData;
|
||||
}
|
||||
|
||||
public enum WindowCompositionAttribute
|
||||
{
|
||||
// ...
|
||||
WCA_ACCENT_POLICY = 19
|
||||
// ...
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
50
Library/WinAPI/Win32Api.cs
Normal file
50
Library/WinAPI/Win32Api.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.Security.Principal;
|
||||
|
||||
namespace CMM.Library.WinAPI
|
||||
{
|
||||
public static class Win32
|
||||
{
|
||||
public const int WM_SETTEXT = 0x000C;
|
||||
public const int WM_CLICK = 0x00F5;
|
||||
public const int CHILDID_SELF = 0;
|
||||
public const int CHILDID_1 = 1;
|
||||
public const int OBJID_CLIENT = -4;
|
||||
|
||||
[DllImport("user32.dll", EntryPoint = "GetWindowText", CharSet = CharSet.Unicode)]
|
||||
public static extern int GetWindowText(IntPtr hwnd, StringBuilder lpString, int cch);
|
||||
[DllImport("user32.dll", EntryPoint = "FindWindowEx", CharSet = CharSet.Auto)]
|
||||
public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||
public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, string lParam);
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
|
||||
[DllImport("User32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
public static extern int SendMessage(IntPtr hWnd, uint msg, int wParam, IntPtr lParam);
|
||||
[DllImport("User32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
public static extern int SendMessage(IntPtr hWnd, uint msg, int wParam, StringBuilder lParam);
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto)]
|
||||
public static extern int PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, string lParam);
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto)]
|
||||
public static extern int MoveWindow(IntPtr hWnd, int x, int y, int nWidth, int nHeight, bool BRePaint);
|
||||
[DllImport("user32.dll")]
|
||||
public static extern int GetWindowRect(IntPtr hwnd, out Rectangle lpRect);
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool SetForegroundWindow(IntPtr hWnd);
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
|
||||
[DllImport("user32.dll")]
|
||||
public static extern int SetWindowCompositionAttribute(IntPtr hwnd, ref WindowCompositionAttributeData data);
|
||||
|
||||
public static bool IsUAC()
|
||||
{
|
||||
var principal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
|
||||
return principal.IsInRole(WindowsBuiltInRole.Administrator);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user