public void Dispose()
        {
            if (eventHandle == IntPtr.Zero)
            {
                return;
            }

            ApiWinEventHook.UnhookWinEvent(eventHandle);
        }
        private static IntPtr AddHook(uint processId,
                                      uint threadId,
                                      ApiWinEventHook.EventId eventIdMin,
                                      ApiWinEventHook.EventId eventIdMax,
                                      ApiWinEventHook.WinEventDelegate eventHandler)
        {
            IntPtr handle = ApiWinEventHook.SetWinEventHook(
                eventIdMin, eventIdMax, IntPtr.Zero, eventHandler,
                processId, threadId, ApiWinEventHook.EventSyncContext.WineventOutofcontext);

            return(handle);
        }
Пример #3
0
 public WinEventHook(IntPtr handle)
 {
     this.handle = handle;
     handlers    = new List <WinEventHookHandler>();
     threadId    = ApiWinEventHook.GetWindowThreadProcessId(handle, out processId);
 }