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
}