static User32() { IntPtr library = DynamicImport.ImportLibrary("user32.dll"); CreateWindowEx = DynamicImport.Import <CreateWindowExDelegate>(library, "CreateWindowExW"); DefWindowProc = DynamicImport.Import <DefWindowProcDelegate>(library, "DefWindowProcW"); DestroyWindow = DynamicImport.Import <DestroyWindowDelegate>(library, "DestroyWindow"); DispatchMessage = DynamicImport.Import <DispatchMessageDelegate>(library, "DispatchMessageW"); GetClientRect = DynamicImport.Import <GetClientRectDelegate>(library, "GetClientRect"); GetWindow = DynamicImport.Import <GetWindowDelegate>(library, "GetWindow"); GetWindowRect = DynamicImport.Import <GetWindowRectDelegate>(library, "GetWindowRect"); IsWindow = DynamicImport.Import <IsWindowDelegate>(library, "IsWindow"); IsWindowVisible = DynamicImport.Import <IsWindowVisibleDelegate>(library, "IsWindowVisible"); MoveWindow = DynamicImport.Import <MoveWindowDelegate>(library, "MoveWindow"); PeekMessage = DynamicImport.Import <PeekMessageWDelegate>(library, "PeekMessageW"); RegisterClassEx = DynamicImport.Import <RegisterClassExDelegate>(library, "RegisterClassExW"); SendMessage = DynamicImport.Import <SendMessageDelegate>(library, "SendMessageW"); SetLayeredWindowAttributes = DynamicImport.Import <SetLayeredWindowAttributesDelegate>(library, "SetLayeredWindowAttributes"); SetWindowPos = DynamicImport.Import <SetWindowPosDelegate>(library, "SetWindowPos"); ShowWindow = DynamicImport.Import <ShowWindowDelegate>(library, "ShowWindow"); TranslateMessage = DynamicImport.Import <TranslateMessageDelegate>(library, "TranslateMessage"); UnregisterClass = DynamicImport.Import <UnregisterClassDelegate>(library, "UnregisterClassW"); UpdateWindow = DynamicImport.Import <UpdateWindowDelegate>(library, "UpdateWindow"); WaitMessage = DynamicImport.Import <WaitMessageDelegate>(library, "WaitMessage"); PostMessage = DynamicImport.Import <PostMessageWDelegate>(library, "PostMessageW"); GetForegroundWindow = DynamicImport.Import <GetForegroundWindowDelegate>(library, "GetForegroundWindow"); try { _setThreadDpiAwarenessContext = DynamicImport.Import <SetThreadDpiAwarenessContextDelegate>(library, "SetThreadDpiAwarenessContext"); } catch { } // ignored }
static User32() { IntPtr library = DynamicImport.ImportLibrary("user32.dll"); CreateWindowEx = DynamicImport.Import <CreateWindowExDelegate>(library, "CreateWindowExW"); DefWindowProc = DynamicImport.Import <DefWindowProcDelegate>(library, "DefWindowProcW"); DestroyWindow = DynamicImport.Import <DestroyWindowDelegate>(library, "DestroyWindow"); DispatchMessage = DynamicImport.Import <DispatchMessageDelegate>(library, "DispatchMessageW"); GetClientRect = DynamicImport.Import <GetClientRectDelegate>(library, "GetClientRect"); GetWindow = DynamicImport.Import <GetWindowDelegate>(library, "GetWindow"); GetWindowRect = DynamicImport.Import <GetWindowRectDelegate>(library, "GetWindowRect"); IsWindow = DynamicImport.Import <IsWindowDelegate>(library, "IsWindow"); IsWindowVisible = DynamicImport.Import <IsWindowVisibleDelegate>(library, "IsWindowVisible"); MoveWindow = DynamicImport.Import <MoveWindowDelegate>(library, "MoveWindow"); PeekMessage = DynamicImport.Import <PeekMessageWDelegate>(library, "PeekMessageW"); RegisterClassEx = DynamicImport.Import <RegisterClassExDelegate>(library, "RegisterClassExW"); SendMessage = DynamicImport.Import <SendMessageDelegate>(library, "SendMessageW"); SetLayeredWindowAttributes = DynamicImport.Import <SetLayeredWindowAttributesDelegate>(library, "SetLayeredWindowAttributes"); SetWindowPos = DynamicImport.Import <SetWindowPosDelegate>(library, "SetWindowPos"); ShowWindow = DynamicImport.Import <ShowWindowDelegate>(library, "ShowWindow"); TranslateMessage = DynamicImport.Import <TranslateMessageDelegate>(library, "TranslateMessage"); UnregisterClass = DynamicImport.Import <UnregisterClassDelegate>(library, "UnregisterClassW"); UpdateWindow = DynamicImport.Import <UpdateWindowDelegate>(library, "UpdateWindow"); WaitMessage = DynamicImport.Import <WaitMessageDelegate>(library, "WaitMessage"); PostMessage = DynamicImport.Import <PostMessageWDelegate>(library, "PostMessageW"); PostQuitMessage = DynamicImport.Import <PostQuitMessageDelegate>(library, "PostQuitMessage"); GetForegroundWindow = DynamicImport.Import <GetForegroundWindowDelegate>(library, "GetForegroundWindow"); GetDesktopWindow = DynamicImport.Import <GenericGetWindowDelegate>(library, "GetDesktopWindow"); GetShellWindow = DynamicImport.Import <GenericGetWindowDelegate>(library, "GetShellWindow"); GetActiveWindow = DynamicImport.Import <GenericGetWindowDelegate>(library, "GetActiveWindow"); FindWindowEx = DynamicImport.Import <FindWindowExWDelegate>(library, "FindWindowExW"); GetWindowInfo = DynamicImport.Import <GetWindowInfoDelegate>(library, "GetWindowInfo"); GetWindowThreadProcessId = DynamicImport.Import <GetWindowThreadProcessIdDelegate>(library, "GetWindowThreadProcessId"); SetForegroundWindow = DynamicImport.Import <SetForegroundWindowDelegate>(library, "SetForegroundWindow"); if (IntPtr.Size == 4) { GetClassLongPtr = DynamicImport.Import <GenericGetWindowLongDelegate>(library, "GetClassLongW"); GetWindowLongPtr = DynamicImport.Import <GenericGetWindowLongDelegate>(library, "GetWindowLongW"); } else { GetClassLongPtr = DynamicImport.Import <GenericGetWindowLongDelegate>(library, "GetClassLongPtrW"); GetWindowLongPtr = DynamicImport.Import <GenericGetWindowLongDelegate>(library, "GetWindowLongPtrW"); } try { _setThreadDpiAwarenessContext = DynamicImport.Import <SetThreadDpiAwarenessContextDelegate>(library, "SetThreadDpiAwarenessContext"); } catch { } // ignored }