📄 nativemethods.cs
字号:
namespace Imps.Client.Utils.Win32
{
using System;
using System.Drawing;
using System.Runtime.InteropServices;
public static class NativeMethods
{
public const int FLASHW_ALL = 3;
public const int FLASHW_CAPTION = 1;
public const int FLASHW_STOP = 0;
public const int FLASHW_TIMER = 4;
public const int FLASHW_TIMERNOFG = 12;
public const int FLASHW_TRAY = 2;
public const int GWL_EXSTYLE = -20;
public const int GWL_STYLE = -16;
public const int GWL_WNDPROC = -4;
[DllImport("user32")]
public static extern bool BringWindowToTop(IntPtr hWnd);
[DllImport("user32.dll")]
public static extern int CallWindowProc(IntPtr lpPrevWndFunc, IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
[DllImport("kernel32.dll", CharSet=CharSet.Auto, SetLastError=true)]
public static extern bool CopyFileEx(string lpExistingFileName, string lpNewFileName, Delegate lpProgressRoutine, IntPtr lpData, ref bool pbCancel, CopyFileFlags dwCopyFlags);
[DllImport("gdi32.dll", SetLastError=true, ExactSpelling=true)]
public static extern IntPtr CreateCompatibleDC(IntPtr hDC);
[DllImport("gdi32.dll", SetLastError=true, ExactSpelling=true)]
public static extern int DeleteDC(IntPtr hDC);
[DllImport("gdi32.dll", SetLastError=true, ExactSpelling=true)]
public static extern int DeleteObject(IntPtr hObj);
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern int DispatchMessage([In] ref Imps.Client.Utils.Win32.MSG msg);
[DllImport("gdi32.dll", SetLastError=true, ExactSpelling=true)]
public static extern IntPtr ExtCreateRegion(IntPtr lpXform, uint nCount, IntPtr rgnData);
[DllImport("user32", CharSet=CharSet.Auto, SetLastError=true)]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]
public static extern int FlashWindow(int hWnd, int bInvert);
[DllImport("user32.dll")]
public static extern bool FlashWindowEx([MarshalAs(UnmanagedType.Struct)] ref FLASHWINFO pfwi);
[DllImport("kernel32.dll", SetLastError=true)]
public static extern bool FreeLibrary(IntPtr hModule);
[DllImport("user32.dll")]
public static extern IntPtr GetActiveWindow();
[DllImport("user32.dll")]
public static extern IntPtr GetAncestor(IntPtr hwnd, uint gaFlags);
[DllImport("user32.dll", SetLastError=true, ExactSpelling=true)]
public static extern IntPtr GetDC(IntPtr hWnd);
[DllImport("user32.dll")]
public static extern IntPtr GetDesktopWindow();
[DllImport("user32.dll")]
public static extern IntPtr GetFocus();
[DllImport("user32.dll")]
public static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll", CharSet=CharSet.Auto, ExactSpelling=true)]
public static extern short GetKeyState(int keyCode);
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern bool GetMessage([In, Out] ref Imps.Client.Utils.Win32.MSG msg, IntPtr hWnd, int uMsgFilterMin, int uMsgFilterMax);
[DllImport("kernel32.dll", CharSet=CharSet.Ansi, ExactSpelling=true)]
public static extern IntPtr GetProcAddress(IntPtr hModule, string procName);
[DllImport("Kernel32.dll")]
internal static extern int GetSystemDefaultLangID();
[DllImport("Kernel32.dll")]
internal static extern int GetSystemDefaultLCID();
[DllImport("Kernel32.dll")]
internal static extern int GetSystemDefaultUILanguage();
[DllImport("user32")]
public static extern int GetSystemMetrics(int nIndex);
[DllImport("Kernel32.dll")]
internal static extern int GetThreadUILanguage();
[DllImport("kernel32.dll", CharSet=CharSet.Auto)]
internal static extern int GetTimeZoneInformation(out TimeZoneInformation lpTimeZoneInformation);
[DllImport("Kernel32.dll")]
internal static extern int GetUserDefaultLangID();
[DllImport("Kernel32.dll")]
internal static extern int GetUserDefaultLCID();
[DllImport("Kernel32.dll")]
internal static extern int GetUserDefaultUILanguage();
[DllImport("user32")]
public static extern IntPtr GetWindow(IntPtr hWnd, uint uCmd);
[DllImport("user32.dll")]
public static extern int GetWindowLong(IntPtr hWnd, int nIndex);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("user32.dll")]
public static extern bool GetWindowPlacement(IntPtr hWnd, ref WINDOWPLACEMENT lpwndpl);
[DllImport("user32.dll")]
public static extern bool GetWindowRect(IntPtr hWnd, out Imps.Client.Utils.Win32.RECT lpRect);
[DllImport("user32.dll", EntryPoint="GetWindowRect")]
public static extern bool GetWindowRectangle(IntPtr hWnd, out Rectangle lpRect);
[DllImport("kernel32.dll")]
public static extern IntPtr LoadLibrary(string lpFileName);
[DllImport("kernel32.dll")]
public static extern IntPtr LocalAlloc([In, MarshalAs(UnmanagedType.I4)] MemoryFlags flags, int size);
[DllImport("kernel32.dll")]
public static extern IntPtr LocalFree(IntPtr memBlock);
[DllImport("ntdll.dll")]
public static extern IntPtr memcpy(IntPtr dst, IntPtr src, int count);
[DllImport("ntdll.dll")]
public static extern unsafe byte* memcpy(byte* dst, byte* src, int count);
[DllImport("ntdll.dll")]
public static extern IntPtr memset(IntPtr dst, int filler, int count);
[DllImport("user32.dll")]
public static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern bool PeekMessage([In, Out] ref Imps.Client.Utils.Win32.MSG msg, IntPtr hwnd, int msgMin, int msgMax, int remove);
[DllImport("user32")]
public static extern bool RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, uint vk);
[DllImport("user32.dll", CharSet=CharSet.Auto, SetLastError=true)]
public static extern uint RegisterWindowMessage(string lpString);
[DllImport("user32.dll", ExactSpelling=true)]
public static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);
[DllImport("gdi32.dll", ExactSpelling=true)]
public static extern IntPtr SelectObject(IntPtr hDC, IntPtr hObj);
[DllImport("kernel32.dll")]
public static extern bool SetProcessWorkingSetSize(IntPtr proc, int min, int max);
[DllImport("gdi32.dll", CharSet=CharSet.Auto)]
public static extern int SetTextCharacterExtra(IntPtr hdc, int nCharExtra);
[DllImport("user32.dll")]
public static extern IntPtr SetWindowLong(IntPtr hWnd, int nIndex, IntPtr nNewLong);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("user32.dll")]
public static extern bool SetWindowPlacement(IntPtr hWnd, ref WINDOWPLACEMENT lpwndpl);
[DllImport("user32.dll")]
public static extern bool SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
[DllImport("shell32.dll")]
public static extern int ShellExecute(IntPtr hWnd, string lpszOp, string lpszFile, string lpszParams, string lpszDir, int FsShowCmd);
[DllImport("user32.dll")]
public static extern bool ShowWindow(IntPtr hWnd, int flags);
[DllImport("user32")]
public static extern bool SystemParametersInfo(uint uiAction, uint uiParam, IntPtr pvParam, uint fWinIni);
[DllImport("user32")]
public static extern bool SystemParametersInfo(uint uiAction, uint uiParam, ref uint pvParam, uint fWinIni);
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern bool TranslateMessage([In, Out] ref Imps.Client.Utils.Win32.MSG msg);
[DllImport("user32.dll")]
public static extern bool UnregisterHotKey(IntPtr hWnd, int id);
[DllImport("user32.dll", SetLastError=true, ExactSpelling=true)]
public static extern int UpdateLayeredWindow(IntPtr hwnd, IntPtr hdcDst, ref Point pptDst, ref Size psize, IntPtr hdcSrc, ref Point pptSrc, int crKey, ref BLENDFUNCTION pblend, int dwFlags);
[StructLayout(LayoutKind.Sequential, Pack=1)]
public struct BLENDFUNCTION
{
public byte BlendOp;
public byte BlendFlags;
public byte SourceConstantAlpha;
public byte AlphaFormat;
}
[StructLayout(LayoutKind.Sequential)]
public struct FLASHWINFO
{
[MarshalAs(UnmanagedType.U4)]
public int cbSize;
public IntPtr hwnd;
[MarshalAs(UnmanagedType.U4)]
public int dwFlags;
[MarshalAs(UnmanagedType.U4)]
public int uCount;
[MarshalAs(UnmanagedType.U4)]
public int dwTimeout;
}
public enum MemoryFlags
{
Fixed = 0,
ZeroInit = 0x40
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -