How to pass null pointer to Win32 API in C# .Net?
I'm looking at the RegisterHotKey Function:
http://msdn.microsoft.com/en-us/library/ms646309(VS.85).aspx
BOOL RegisterHotKey(
__in HWND hWnd,
__in int id,
__in UINT fsModifiers,
__in UINT vk
);
I've been using IntPtr
to pass in the first argument, which works fine in most cases. But now I need to deliberately pass a null pointer as the first argument, which IntPtr
(deliberately) will not do. I'm new to .Net, and this has me perplexed. How c开发者_如何学Pythonan I do this?
Use IntPtr.Zero
for NULL
For example:
public void Example() {
...
RegisterHotKey(IntPtr.Zero, id, mod, vk);
}
[DllImportAttribute("user32.dll", EntryPoint="RegisterHotKey")]
[return: MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.Bool)]
public static extern bool RegisterHotKey(
IntPtr hWnd,
int id,
uint fsModifiers,
uint vk);
精彩评论