public virtual void Subscribe() { if (_hooksHandle != 0) { return; } lock (_padLock) { // install Mouse hook only if it is not installed and must be installed if (_hooksHandle == 0) { _hooksProc = HooksProc; //install hook _hooksHandle = ChoUser32.SetWindowsHookEx( (int)_hookType, _hooksProc, IntPtr.Zero, //Marshal.GetHINSTANCE(Assembly.GetExecutingAssembly().GetModules()[0]), 0); //If SetWindowsHookEx fails. if (_hooksHandle == 0) { ChoWin32Exception.CheckNThrowException(); } } } }
public static extern int SetWindowsHookEx( int idHook, ChoHooksProc lpfn, IntPtr hMod, int dwThreadId);