private MainThread() { WinImports.EnumWindows(WindowProc, IntPtr.Zero); _newCallback = WndProc; // Pins WndProc - will not be garbage collected. _oldCallback = WinImports.SetWindowLong((IntPtr)_hWnd, GWL_WNDPROC, Marshal.GetFunctionPointerForDelegate(_newCallback)); mtId = Process.GetCurrentProcess().Threads[0].Id; }
public static void Init() { if (Applied) { return; } WinImports.EnumWindows(WindowProc, IntPtr.Zero); _newCallback = WndProc; // Pins WndProc - will not be garbage collected. _oldCallback = WinImports.SetWindowLong(HWnD, GWL_WNDPROC, Marshal.GetFunctionPointerForDelegate(_newCallback)); Applied = true; }