51 lines
2.6 KiB
C#
51 lines
2.6 KiB
C#
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);
|
|
}
|
|
}
|
|
}
|