/// <summary> /// stops listening. /// </summary> private void removeHook() { DLLImports.UnhookWinEvent(m_hhook); m_hhook = IntPtr.Zero; dele = null; }
/// <summary> /// start listening /// </summary> private void enableHook() { dele = new DLLImports.WinEventDelegate(WinEventProc); m_hhook = DLLImports.SetWinEventHook(EVENT_SYSTEM_FOREGROUND, EVENT_SYSTEM_FOREGROUND, IntPtr.Zero, dele, 0, 0, WINEVENT_OUTOFCONTEXT); }