static HwndSubclass() { DetachMessage = UnsafeNativeMethods.RegisterWindowMessage("HwndSubclass.DetachMessage"); // Go find the address of DefWindowProc. IntPtr hModuleUser32 = UnsafeNativeMethods.GetModuleHandle(ExternDll.User32); IntPtr address = UnsafeNativeMethods.GetProcAddress(new HandleRef(null, hModuleUser32), "DefWindowProcW"); DefWndProc = address; }
private static IntPtr GetUser32ProcAddress(string export) { IntPtr hModule = UnsafeNativeMethods.GetModuleHandle(ExternDll.User32); if (hModule != IntPtr.Zero) { return(UnsafeNativeMethods.GetProcAddress(new HandleRef(null, hModule), export)); } return(IntPtr.Zero); }