public static WinEventHook GetInstance() { if (_instance == null) { _instance = new WinEventHook(); } return(_instance); }
static void WinEventProc(IntPtr hWinEventHook, uint eventType, IntPtr hwnd, int idObject, int idChild, uint dwEventThread, uint dwmsEventTime) { uint processId; GetWindowThreadProcessId(hwnd, out processId); Process p = Process.GetProcessById((int)processId); int windowTextLength = GetWindowTextLength(hwnd); StringBuilder sb = new StringBuilder(windowTextLength + 1); GetWindowTextA(hwnd, sb, sb.Capacity); WinEventHookEventArgs e = new WinEventHookEventArgs(); e.Handle = hwnd; e.ProcessId = processId; e.MainWindowTitle = p.MainWindowTitle; e.ProcessName = p.ProcessName; e.WindowText = sb.ToString(); WinEventHook.GetInstance().DispatchWinEventHookEvent(e); }
public static WinEventHook GetInstance() { if (_instance == null) _instance = new WinEventHook(); return _instance; }