2020-01-15 17:59:29 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace CC_Functions.W32.Native
|
|
|
|
|
{
|
|
|
|
|
internal static class user32
|
|
|
|
|
{
|
2020-01-16 19:50:31 +01:00
|
|
|
|
public delegate bool EnumDelegate(IntPtr hWnd, int lParam);
|
|
|
|
|
|
|
|
|
|
public delegate IntPtr LowLevelProc(int nCode, IntPtr wParam, IntPtr lParam);
|
|
|
|
|
|
2020-01-15 17:59:29 +01:00
|
|
|
|
[DllImport("user32.dll")]
|
|
|
|
|
public static extern IntPtr GetWindowDC(IntPtr hWnd);
|
|
|
|
|
|
|
|
|
|
[DllImport("user32.dll", SetLastError = true)]
|
|
|
|
|
[return: MarshalAs(UnmanagedType.Bool)]
|
|
|
|
|
public static extern bool ExitWindowsEx(Power.ExitWindows uFlags, Power.ShutdownReason dwReason);
|
2020-01-16 19:50:31 +01:00
|
|
|
|
|
2020-01-15 17:59:29 +01:00
|
|
|
|
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
|
|
|
|
|
public static extern short GetKeyState(int keyCode);
|
|
|
|
|
|
|
|
|
|
[DllImport("user32.dll", EntryPoint = "GetDC")]
|
|
|
|
|
public static extern IntPtr GetDC(IntPtr ptr);
|
|
|
|
|
|
|
|
|
|
[DllImport("user32.dll", EntryPoint = "GetDesktopWindow")]
|
|
|
|
|
public static extern IntPtr GetDesktopWindow();
|
|
|
|
|
|
|
|
|
|
[DllImport("user32.dll", EntryPoint = "ReleaseDC")]
|
|
|
|
|
public static extern IntPtr ReleaseDC(IntPtr hWnd, IntPtr hDc);
|
|
|
|
|
|
|
|
|
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
|
|
|
|
public static extern IntPtr SetWindowsHookEx(int idHook, LowLevelProc lpfn, IntPtr hMod,
|
|
|
|
|
uint dwThreadId);
|
|
|
|
|
|
|
|
|
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
|
|
|
|
[return: MarshalAs(UnmanagedType.Bool)]
|
|
|
|
|
public static extern bool UnhookWindowsHookEx(IntPtr hhk);
|
|
|
|
|
|
|
|
|
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
|
|
|
|
public static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, IntPtr lParam);
|
2020-01-16 19:50:31 +01:00
|
|
|
|
|
2020-01-15 17:59:29 +01:00
|
|
|
|
[DllImport("user32.dll")]
|
|
|
|
|
[return: MarshalAs(UnmanagedType.Bool)]
|
|
|
|
|
public static extern bool IsWindowVisible(IntPtr hWnd);
|
2020-01-16 19:50:31 +01:00
|
|
|
|
|
2020-01-15 17:59:29 +01:00
|
|
|
|
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Ansi)]
|
|
|
|
|
public static extern long GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);
|
|
|
|
|
|
|
|
|
|
[DllImport("user32.dll")]
|
|
|
|
|
public static extern IntPtr GetForegroundWindow();
|
|
|
|
|
|
|
|
|
|
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
|
|
|
|
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
|
|
|
|
|
|
|
|
|
|
[DllImport("user32.dll")]
|
|
|
|
|
public static extern IntPtr WindowFromPoint(int xPoint, int yPoint);
|
|
|
|
|
|
2020-02-01 15:32:03 +01:00
|
|
|
|
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
|
|
|
|
public static extern bool SetWindowTextW(IntPtr hWnd, string lpString);
|
2020-01-15 17:59:29 +01:00
|
|
|
|
|
|
|
|
|
[DllImport("user32.dll", SetLastError = true)]
|
|
|
|
|
public static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);
|
|
|
|
|
|
|
|
|
|
[DllImport("user32.dll")]
|
|
|
|
|
public static extern bool SetForegroundWindow(IntPtr hWnd);
|
|
|
|
|
|
|
|
|
|
[DllImport("user32.dll")]
|
|
|
|
|
public static extern bool EnableWindow(IntPtr hWnd, bool bEnable);
|
|
|
|
|
|
|
|
|
|
[DllImport("user32.dll")]
|
|
|
|
|
[return: MarshalAs(UnmanagedType.Bool)]
|
|
|
|
|
public static extern bool IsWindowEnabled(IntPtr hWnd);
|
|
|
|
|
|
|
|
|
|
[DllImport("user32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
|
|
|
|
|
[return: MarshalAs(UnmanagedType.Bool)]
|
|
|
|
|
public static extern bool DestroyWindow(IntPtr hwnd);
|
|
|
|
|
|
|
|
|
|
[DllImport("user32.dll")]
|
|
|
|
|
[return: MarshalAs(UnmanagedType.Bool)]
|
|
|
|
|
public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy,
|
|
|
|
|
uint uFlags);
|
|
|
|
|
|
|
|
|
|
[DllImport("user32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
|
|
|
|
|
public static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);
|
|
|
|
|
|
|
|
|
|
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall,
|
|
|
|
|
ExactSpelling = true, SetLastError = true)]
|
|
|
|
|
public static extern bool GetWindowRect(IntPtr hWnd, ref RECT rect);
|
|
|
|
|
|
|
|
|
|
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
|
|
|
|
public static extern int GetWindowTextLength(IntPtr hWnd);
|
|
|
|
|
|
|
|
|
|
[DllImport("user32.dll")]
|
|
|
|
|
[return: MarshalAs(UnmanagedType.Bool)]
|
|
|
|
|
public static extern bool IsWindow(IntPtr hWnd);
|
|
|
|
|
|
|
|
|
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
|
|
|
|
public static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, int lParam);
|
|
|
|
|
|
|
|
|
|
[DllImport("user32.dll")]
|
|
|
|
|
public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
|
|
|
|
|
|
|
|
|
|
[DllImport("user32.dll", SetLastError = true)]
|
|
|
|
|
public static extern int GetWindowLong(IntPtr hWnd, int nIndex);
|
|
|
|
|
|
|
|
|
|
[DllImport("user32.dll", EntryPoint = "EnumDesktopWindows", ExactSpelling = false, CharSet = CharSet.Auto,
|
|
|
|
|
SetLastError = true)]
|
|
|
|
|
public static extern bool EnumDesktopWindows(IntPtr hDesktop, EnumDelegate lpEnumCallbackFunction,
|
|
|
|
|
IntPtr lParam);
|
2020-01-16 19:50:31 +01:00
|
|
|
|
|
2020-01-15 17:59:29 +01:00
|
|
|
|
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
|
|
|
|
public static extern int SystemParametersInfo(int uAction, int uParam, string lpvParam, int fuWinIni);
|
2020-01-16 19:50:31 +01:00
|
|
|
|
|
2020-01-15 17:59:29 +01:00
|
|
|
|
[DllImport("user32.dll")]
|
|
|
|
|
public static extern IntPtr GetDCEx(IntPtr hWnd, IntPtr hrgnClip, uint flags);
|
|
|
|
|
|
|
|
|
|
[DllImport("user32.dll")]
|
|
|
|
|
[return: MarshalAs(UnmanagedType.Bool)]
|
|
|
|
|
public static extern bool EnumWindows(EnumDelegate lpEnumFunc, IntPtr lParam);
|
|
|
|
|
|
|
|
|
|
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
2020-01-16 19:50:31 +01:00
|
|
|
|
public static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string className,
|
|
|
|
|
IntPtr windowTitle);
|
2020-01-15 17:59:29 +01:00
|
|
|
|
|
|
|
|
|
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
2020-01-16 19:50:31 +01:00
|
|
|
|
public static extern IntPtr SendMessageTimeout(IntPtr windowHandle, uint Msg, IntPtr wParam, IntPtr lParam,
|
|
|
|
|
uint flags, uint timeout, out IntPtr result);
|
2020-03-11 18:40:58 +01:00
|
|
|
|
|
|
|
|
|
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
|
|
|
|
|
public static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint cButtons, uint dwExtraInfo);
|
2020-01-15 17:59:29 +01:00
|
|
|
|
}
|
|
|
|
|
}
|