BOOL UnregisterHotKey( HWND hWnd, int id ); 转换成C#代码,那么首先就要引用命名空间System.Runtime.InteropServices;来加载非托管类user32.dll。于是有了:
[DllImport("user32.dll", SetLastError=true)] public static extern bool RegisterHotKey( IntPtr hWnd, // handle to window int id, // hot key identifier KeyModifiers fsModifiers, // key-modifier options Keys vk // virtual-key code );
[DllImport("user32.dll", SetLastError=true)] public static extern bool UnregisterHotKey( IntPtr hWnd, // handle to window int id // hot key identifier );
[Flags()] public enum KeyModifiers { None = 0, Alt = 1, Control = 2, Shift = 4, Windows = 8 }