Back to Home
Digging into user32.dll.
October 01, 2011 • 6 minutes read

Most of the times, we need to interact with native windows actions in WPF or Win Forms. C# provides a better way to import an assembly dynamically and we can effectively use the methods of native System assembly.
class Example
{
// Use DllImport to import the Win32 MessageBox function.
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
public static extern int MessageBox(IntPtr hWnd, String text, String caption, uint type);
static void Main()
{
// Call the MessageBox function using platform invoke.
MessageBox(new IntPtr(0), "Hello World!", "Hello Dialog", 0);
}
}
One of the most useful assembly if user32 assembly which contains the 732 methods.
ActivateKeyboardLayout 1
AdjustWindowRect 2 AdjustWindowRectEx 3 AlignRects 4 AllowForegroundActivation 5 AllowSetForegroundWindow 6 AnimateWindow 7 AnyPopup 8 AppendMenuA 9 AppendMenuW 10 ArrangeIconicWindows 11 AttachThreadInput 12 BeginDeferWindowPos 13 BeginPaint 14 BlockInput 15 BringWindowToTop 16 BroadcastSystemMessage 17 BroadcastSystemMessageA 18 BroadcastSystemMessageExA 19 BroadcastSystemMessageExW 20 BroadcastSystemMessageW 21 BuildReasonArray 22 CalcMenuBar 23 CallMsgFilter 24 CallMsgFilterA 25 CallMsgFilterW 26 CallNextHookEx 27 CallWindowProcA 28 CallWindowProcW 29 CascadeChildWindows 30 CascadeWindows 31 ChangeClipboardChain 32 ChangeDisplaySettingsA 33 ChangeDisplaySettingsExA 34 ChangeDisplaySettingsExW 35 ChangeDisplaySettingsW 36 ChangeMenuA 37 ChangeMenuW 38 CharLowerA 39 CharLowerBuffA 40 CharLowerBuffW 41 CharLowerW 42 CharNextA 43 CharNextExA 44 CharNextW 45 CharPrevA 46 CharPrevExA 47 CharPrevW 48 CharToOemA 49 CharToOemBuffA 50 CharToOemBuffW 51 CharToOemW 52 CharUpperA 53 CharUpperBuffA 54 CharUpperBuffW 55 CharUpperW 56 CheckDlgButton 57 CheckMenuItem 58 CheckMenuRadioItem 59 CheckRadioButton 60 ChildWindowFromPoint 61 ChildWindowFromPointEx 62 CliImmSetHotKey 63 ClientThreadSetup 64 ClientToScreen 65 ClipCursor 66 CloseClipboard 67 CloseDesktop 68 CloseWindow 69 CloseWindowStation 70 CopyAcceleratorTableA 71 CopyAcceleratorTableW 72 CopyIcon 73 CopyImage 74 CopyRect 75 CountClipboardFormats 76 CreateAcceleratorTableA 77 CreateAcceleratorTableW 78 CreateCaret 79 CreateCursor 80 CreateDesktopA 81 CreateDesktopW 82 CreateDialogIndirectParamA 83 CreateDialogIndirectParamAorW 84 CreateDialogIndirectParamW 85 CreateDialogParamA 86 CreateDialogParamW 87 CreateIcon 88 CreateIconFromResource 89 CreateIconFromResourceEx 90 CreateIconIndirect 91 CreateMDIWindowA 92 CreateMDIWindowW 93 CreateMenu 94 CreatePopupMenu 95 CreateSystemThreads 96 CreateWindowExA 97 CreateWindowExW 98 CreateWindowStationA 99 CreateWindowStationW 100 CsrBroadcastSystemMessageExW 101 CtxInitUser32 102 DdeAbandonTransaction 103 DdeAccessData 104 DdeAddData 105 DdeClientTransaction 106 DdeCmpStringHandles 107 DdeConnect 108 DdeConnectList 109 DdeCreateDataHandle 110 DdeCreateStringHandleA 111 DdeCreateStringHandleW 112 DdeDisconnect 113 DdeDisconnectList 114 DdeEnableCallback 115 DdeFreeDataHandle 116 DdeFreeStringHandle 117 DdeGetData 118 DdeGetLastError 119 DdeGetQualityOfService 120 DdeImpersonateClient 121 DdeInitializeA 122 DdeInitializeW 123 DdeKeepStringHandle 124 DdeNameService 125 DdePostAdvise 126 DdeQueryConvInfo 127 DdeQueryNextServer 128 DdeQueryStringA 129 DdeQueryStringW 130 DdeReconnect 131 DdeSetQualityOfService 132 DdeSetUserHandle 133 DdeUnaccessData 134 DdeUninitialize 135 DefDlgProcA 136 DefDlgProcW 137 DefFrameProcA 138 DefFrameProcW 139 DefMDIChildProcA 140 DefMDIChildProcW 141 DefRawInputProc 142 DefWindowProcA 143 DefWindowProcW 144 DeferWindowPos 145 DeleteMenu 146 DeregisterShellHookWindow 147 DestroyAcceleratorTable 148 DestroyCaret 149 DestroyCursor 150 DestroyIcon 151 DestroyMenu 152 DestroyReasons 153 DestroyWindow 154 DeviceEventWorker 155 DialogBoxIndirectParamA 156 DialogBoxIndirectParamAorW 157 DialogBoxIndirectParamW 158 DialogBoxParamA 159 DialogBoxParamW 160 DisableProcessWindowsGhosting 161 DispatchMessageA 162 DispatchMessageW 163 DisplayExitWindowsWarnings 164 DlgDirListA 165 DlgDirListComboBoxA 166 DlgDirListComboBoxW 167 DlgDirListW 168 DlgDirSelectComboBoxExA 169 DlgDirSelectComboBoxExW 170 DlgDirSelectExA 171 DlgDirSelectExW 172 DragDetect 173 DragObject 174 DrawAnimatedRects 175 DrawCaption 176 DrawCaptionTempA 177 DrawCaptionTempW 178 DrawEdge 179 DrawFocusRect 180 DrawFrame 181 DrawFrameControl 182 DrawIcon 183 DrawIconEx 184 DrawMenuBar 185 DrawMenuBarTemp 186 DrawStateA 187 DrawStateW 188 DrawTextA 189 DrawTextExA 190 DrawTextExW 191 DrawTextW 192 EditWndProc 193 EmptyClipboard 194 EnableMenuItem 195 EnableScrollBar 196 EnableWindow 197 EndDeferWindowPos 198 EndDialog 199 EndMenu 200 EndPaint 201 EndTask 202 EnterReaderModeHelper 203 EnumChildWindows 204 EnumClipboardFormats 205 EnumDesktopWindows 206 EnumDesktopsA 207 EnumDesktopsW 208 EnumDisplayDevicesA 209 EnumDisplayDevicesW 210 EnumDisplayMonitors 211 EnumDisplaySettingsA 212 EnumDisplaySettingsExA 213 EnumDisplaySettingsExW 214 EnumDisplaySettingsW 215 EnumPropsA 216 EnumPropsExA 217 EnumPropsExW 218 EnumPropsW 219 EnumThreadWindows 220 EnumWindowStationsA 221 EnumWindowStationsW 222 EnumWindows 223 EqualRect 224 ExcludeUpdateRgn 225 ExitWindowsEx 226 FillRect 227 FindWindowA 228 FindWindowExA 229 FindWindowExW 230 FindWindowW 231 FlashWindow 232 FlashWindowEx 233 FrameRect 234 FreeDDElParam 235 GetActiveWindow 236 GetAltTabInfo 237 GetAltTabInfoA 238 GetAltTabInfoW 239 GetAncestor 240 GetAppCompatFlags 242 GetAppCompatFlags2 241 GetAsyncKeyState 243 GetCapture 244 GetCaretBlinkTime 245 GetCaretPos 246 GetClassInfoA 247 GetClassInfoExA 248 GetClassInfoExW 249 GetClassInfoW 250 GetClassLongA 251 GetClassLongW 252 GetClassNameA 253 GetClassNameW 254 GetClassWord 255 GetClientRect 256 GetClipCursor 257 GetClipboardData 258 GetClipboardFormatNameA 259 GetClipboardFormatNameW 260 GetClipboardOwner 261 GetClipboardSequenceNumber 262 GetClipboardViewer 263 GetComboBoxInfo 264 GetCursor 265 GetCursorFrameInfo 266 GetCursorInfo 267 GetCursorPos 268 GetDC 269 GetDCEx 270 GetDesktopWindow 271 GetDialogBaseUnits 272 GetDlgCtrlID 273 GetDlgItem 274 GetDlgItemInt 275 GetDlgItemTextA 276 GetDlgItemTextW 277 GetDoubleClickTime 278 GetFocus 279 GetForegroundWindow 280 GetGUIThreadInfo 281 GetGuiResources 282 GetIconInfo 283 GetInputDesktop 284 GetInputState 285 GetInternalWindowPos 286 GetKBCodePage 287 GetKeyNameTextA 288 GetKeyNameTextW 289 GetKeyState 290 GetKeyboardLayout 291 GetKeyboardLayoutList 292 GetKeyboardLayoutNameA 293 GetKeyboardLayoutNameW 294 GetKeyboardState 295 GetKeyboardType 296 GetLastActivePopup 297 GetLastInputInfo 298 GetLayeredWindowAttributes 299 GetListBoxInfo 300 GetMenu 301 GetMenuBarInfo 302 GetMenuCheckMarkDimensions 303 GetMenuContextHelpId 304 GetMenuDefaultItem 305 GetMenuInfo 306 GetMenuItemCount 307 GetMenuItemID 308 GetMenuItemInfoA 309 GetMenuItemInfoW 310 GetMenuItemRect 311 GetMenuState 312 GetMenuStringA 313 GetMenuStringW 314 GetMessageA 315 GetMessageExtraInfo 316 GetMessagePos 317 GetMessageTime 318 GetMessageW 319 GetMonitorInfoA 320 GetMonitorInfoW 321 GetMouseMovePointsEx 322 GetNextDlgGroupItem 323 GetNextDlgTabItem 324 GetOpenClipboardWindow 325 GetParent 326 GetPriorityClipboardFormat 327 GetProcessDefaultLayout 328 GetProcessWindowStation 329 GetProgmanWindow 330 GetPropA 331 GetPropW 332 GetQueueStatus 333 GetRawInputBuffer 334 GetRawInputData 335 GetRawInputDeviceInfoA 336 GetRawInputDeviceInfoW 337 GetRawInputDeviceList 338 GetReasonTitleFromReasonCode 339 GetRegisteredRawInputDevices 340 GetScrollBarInfo 341 GetScrollInfo 342 GetScrollPos 343 GetScrollRange 344 GetShellWindow 345 GetSubMenu 346 GetSysColor 347 GetSysColorBrush 348 GetSystemMenu 349 GetSystemMetrics 350 GetTabbedTextExtentA 351 GetTabbedTextExtentW 352 GetTaskmanWindow 353 GetThreadDesktop 354 GetTitleBarInfo 355 GetTopWindow 356 GetUpdateRect 357 GetUpdateRgn 358 GetUserObjectInformationA 359 GetUserObjectInformationW 360 GetUserObjectSecurity 361 GetWinStationInfo 362 GetWindow 363 GetWindowContextHelpId 364 GetWindowDC 365 GetWindowInfo 366 GetWindowLongA 367 GetWindowLongW 368 GetWindowModuleFileName 369 GetWindowModuleFileNameA 370 GetWindowModuleFileNameW 371 GetWindowPlacement 372 GetWindowRect 373 GetWindowRgn 374 GetWindowRgnBox 375 GetWindowTextA 376 GetWindowTextLengthA 377 GetWindowTextLengthW 378 GetWindowTextW 379 GetWindowThreadProcessId 380 GetWindowWord 381 GrayStringA 382 GrayStringW 383 HideCaret 384 HiliteMenuItem 385 IMPGetIMEA 386 IMPGetIMEW 387 IMPQueryIMEA 388 IMPQueryIMEW 389 IMPSetIMEA 390 IMPSetIMEW 391 ImpersonateDdeClientWindow 392 InSendMessage 393 InSendMessageEx 394 InflateRect 395 InitializeLpkHooks 396 InitializeWin32EntryTable 397 InsertMenuA 398 InsertMenuItemA 399 InsertMenuItemW 400 InsertMenuW 401 InternalGetWindowText 402 IntersectRect 403 InvalidateRect 404 InvalidateRgn 405 InvertRect 406 IsCharAlphaA 407 IsCharAlphaNumericA 408 IsCharAlphaNumericW 409 IsCharAlphaW 410 IsCharLowerA 411 IsCharLowerW 412 IsCharUpperA 413 IsCharUpperW 414 IsChild 415 IsClipboardFormatAvailable 416 IsDialogMessage 417 IsDialogMessageA 418 IsDialogMessageW 419 IsDlgButtonChecked 420 IsGUIThread 421 IsHungAppWindow 422 IsIconic 423 IsMenu 424 IsRectEmpty 425 IsServerSideWindow 426 IsWinEventHookInstalled 427 IsWindow 428 IsWindowEnabled 429 IsWindowInDestroy 430 IsWindowUnicode 431 IsWindowVisible 432 IsZoomed 433 KillSystemTimer 434 KillTimer 435 LoadAcceleratorsA 436 LoadAcceleratorsW 437 LoadBitmapA 438 LoadBitmapW 439 LoadCursorA 440 LoadCursorFromFileA 441 LoadCursorFromFileW 442 LoadCursorW 443 LoadIconA 444 LoadIconW 445 LoadImageA 446 LoadImageW 447 LoadKeyboardLayoutA 448 LoadKeyboardLayoutEx 449 LoadKeyboardLayoutW 450 LoadLocalFonts 451 LoadMenuA 452 LoadMenuIndirectA 453 LoadMenuIndirectW 454 LoadMenuW 455 LoadRemoteFonts 456 LoadStringA 457 LoadStringW 458 LockSetForegroundWindow 459 LockWindowStation 460 LockWindowUpdate 461 LockWorkStation 462 LookupIconIdFromDirectory 463 LookupIconIdFromDirectoryEx 464 MBToWCSEx 465 MB_GetString 466 MapDialogRect 467 MapVirtualKeyA 468 MapVirtualKeyExA 469 MapVirtualKeyExW 470 MapVirtualKeyW 471 MapWindowPoints 472 MenuItemFromPoint 473 MenuWindowProcA 474 MenuWindowProcW 475 MessageBeep 476 MessageBoxA 477 MessageBoxExA 478 MessageBoxExW 479 MessageBoxIndirectA 480 MessageBoxIndirectW 481 MessageBoxTimeoutA 482 MessageBoxTimeoutW 483 MessageBoxW 484 ModifyMenuA 485 ModifyMenuW 486 MonitorFromPoint 487 MonitorFromRect 488 MonitorFromWindow 489 MoveWindow 490 MsgWaitForMultipleObjects 491 MsgWaitForMultipleObjectsEx 492 NotifyWinEvent 493 OemKeyScan 494 OemToCharA 495 OemToCharBuffA 496 OemToCharBuffW 497 OemToCharW 498 OffsetRect 499 OpenClipboard 500 OpenDesktopA 501 OpenDesktopW 502 OpenIcon 503 OpenInputDesktop 504 OpenWindowStationA 505 OpenWindowStationW 506 PackDDElParam 507 PaintDesktop 508 PaintMenuBar 509 PeekMessageA 510 PeekMessageW 511 PostMessageA 512 PostMessageW 513 PostQuitMessage 514 PostThreadMessageA 515 PostThreadMessageW 516 PrintWindow 517 PrivateExtractIconExA 518 PrivateExtractIconExW 519 PrivateExtractIconsA 520 PrivateExtractIconsW 521 PrivateSetDbgTag 522 PrivateSetRipFlags 523 PtInRect 524 QuerySendMessage 525 QueryUserCounters 526 RealChildWindowFromPoint 527 RealGetWindowClass 528 RealGetWindowClassA 529 RealGetWindowClassW 530 ReasonCodeNeedsBugID 531 ReasonCodeNeedsComment 532 RecordShutdownReason 533 RedrawWindow 534 RegisterClassA 535 RegisterClassExA 536 RegisterClassExW 537 RegisterClassW 538 RegisterClipboardFormatA 539 RegisterClipboardFormatW 540 RegisterDeviceNotificationA 541 RegisterDeviceNotificationW 542 RegisterHotKey 543 RegisterLogonProcess 544 RegisterMessagePumpHook 545 RegisterRawInputDevices 546 RegisterServicesProcess 547 RegisterShellHookWindow 548 RegisterSystemThread 549 RegisterTasklist 550 RegisterUserApiHook 551 RegisterWindowMessageA 552 RegisterWindowMessageW 553 ReleaseCapture 554 ReleaseDC 555 RemoveMenu 556 RemovePropA 557 RemovePropW 558 ReplyMessage 559 ResolveDesktopForWOW 560 ReuseDDElParam 561 ScreenToClient 562 ScrollChildren 563 ScrollDC 564 ScrollWindow 565 ScrollWindowEx 566 SendDlgItemMessageA 567 SendDlgItemMessageW 568 SendIMEMessageExA 569 SendIMEMessageExW 570 SendInput 571 SendMessageA 572 SendMessageCallbackA 573 SendMessageCallbackW 574 SendMessageTimeoutA 575 SendMessageTimeoutW 576 SendMessageW 577 SendNotifyMessageA 578 SendNotifyMessageW 579 SetActiveWindow 580 SetCapture 581 SetCaretBlinkTime 582 SetCaretPos 583 SetClassLongA 584 SetClassLongW 585 SetClassWord 586 SetClipboardData 587 SetClipboardViewer 588 SetConsoleReserveKeys 589 SetCursor 590 SetCursorContents 591 SetCursorPos 592 SetDebugErrorLevel 593 SetDeskWallpaper 594 SetDlgItemInt 595 SetDlgItemTextA 596 SetDlgItemTextW 597 SetDoubleClickTime 598 SetFocus 599 SetForegroundWindow 600 SetInternalWindowPos 601 SetKeyboardState 602 SetLastErrorEx 603 SetLayeredWindowAttributes 604 SetLogonNotifyWindow 605 SetMenu 606 SetMenuContextHelpId 607 SetMenuDefaultItem 608 SetMenuInfo 609 SetMenuItemBitmaps 610 SetMenuItemInfoA 611 SetMenuItemInfoW 612 SetMessageExtraInfo 613 SetMessageQueue 614 SetParent 615 SetProcessDefaultLayout 616 SetProcessWindowStation 617 SetProgmanWindow 618 SetPropA 619 SetPropW 620 SetRect 621 SetRectEmpty 622 SetScrollInfo 623 SetScrollPos 624 SetScrollRange 625 SetShellWindow 626 SetShellWindowEx 627 SetSysColors 628 SetSysColorsTemp 629 SetSystemCursor 630 SetSystemMenu 631 SetSystemTimer 632 SetTaskmanWindow 633 SetThreadDesktop 634 SetTimer 635 SetUserObjectInformationA 636 SetUserObjectInformationW 637 SetUserObjectSecurity 638 SetWinEventHook 639 SetWindowContextHelpId 640 SetWindowLongA 641 SetWindowLongW 642 SetWindowPlacement 643 SetWindowPos 644 SetWindowRgn 645 SetWindowStationUser 646 SetWindowTextA 647 SetWindowTextW 648 SetWindowWord 649 SetWindowsHookA 650 SetWindowsHookExA 651 SetWindowsHookExW 652 SetWindowsHookW 653 ShowCaret 654 ShowCursor 655 ShowOwnedPopups 656 ShowScrollBar 657 ShowStartGlass 658 ShowWindow 659 ShowWindowAsync 660 SoftModalMessageBox 661 SubtractRect 662 SwapMouseButton 663 SwitchDesktop 664 SwitchToThisWindow 665 SystemParametersInfoA 666 SystemParametersInfoW 667 TabbedTextOutA 668 TabbedTextOutW 669 TileChildWindows 670 TileWindows 671 ToAscii 672 ToAsciiEx 673 ToUnicode 674 ToUnicodeEx 675 TrackMouseEvent 676 TrackPopupMenu 677 TrackPopupMenuEx 678 TranslateAccelerator 679 TranslateAcceleratorA 680 TranslateAcceleratorW 681 TranslateMDISysAccel 682 TranslateMessage 683 TranslateMessageEx 684 UnhookWinEvent 685 UnhookWindowsHook 686 UnhookWindowsHookEx 687 UnionRect 688 UnloadKeyboardLayout 689 UnlockWindowStation 690 UnpackDDElParam 691 UnregisterClassA 692 UnregisterClassW 693 UnregisterDeviceNotification 694 UnregisterHotKey 695 UnregisterMessagePumpHook 696 UnregisterUserApiHook 697 UpdateLayeredWindow 698 UpdatePerUserSystemParameters 699 UpdateWindow 700 User32InitializeImmEntryTable 701 UserClientDllInitialize 702 UserHandleGrantAccess 703 UserLpkPSMTextOut 704 UserLpkTabbedTextOut 705 UserRealizePalette 706 UserRegisterWowHandlers 707 VRipOutput 708 VTagOutput 709 ValidateRect 710 ValidateRgn 711 VkKeyScanA 712 VkKeyScanExA 713 VkKeyScanExW 714 VkKeyScanW 715 WCSToMBEx 716 WINNLSEnableIME 717 WINNLSGetEnableStatus 718 WINNLSGetIMEHotkey 719 WaitForInputIdle 720 WaitMessage 721 Win32PoolAllocationStats 722 WinHelpA 723 WinHelpW 724 WindowFromDC 725 WindowFromPoint 726 keybd_event 727 mouse_event 728 wsprintfA 729 wsprintfW 730 wvsprintfA 731 wvsprintfW 732 |