public MessageHook(IntPtr window) { int threadId = GetWindowThreadProcessId(window, IntPtr.Zero); IntPtr hr; if ((hr = SetWindowsHookEx( /*WH_GETMESSAGE*/ 3, (proc = __MessageHookProc), IntPtr.Zero, threadId)) == IntPtr.Zero) { throw new Win32Exception(); } hookfunc = hr; }
public MessageHook(IntPtr window) { int threadId = GetWindowThreadProcessId(window, IntPtr.Zero); IntPtr hr; if ((hr = SetWindowsHookEx(/*WH_GETMESSAGE*/ 3, (proc = __MessageHookProc), IntPtr.Zero, threadId)) == IntPtr.Zero) { throw new Win32Exception(); } hookfunc = hr; form = (Form)Form.FromHandle(window); }
static extern IntPtr SetWindowsHookEx(int type, MessageHookProc hook, IntPtr module, int threadId);
extern static IntPtr SetWindowsHookEx(int type, MessageHookProc hook, IntPtr module, int threadId);