Skip to main content

WinAPI Shim Reference

This page lists the Win32 APIs available through XPF's shim layer. These shims exist to support third-party WPF controls on non-Windows platforms. They are not a general-purpose Win32 emulation layer.

For setup and configuration, see Win32 API Shims.

note

"Shimmed" means XPF intercepts the call and provides a cross-platform implementation. The behavior may not be identical to native Win32 in all cases. Functions marked with (W) have both ANSI and Unicode variants available.

user32.dll

Window creation and lifecycle

FunctionDescription
CreateWindowEx (W)Creates a window with extended styles. Returns a virtual HWND managed by XPF.
RegisterClassRegisters a window class.
RegisterClassExWRegisters a window class (extended).
DestroyWindowDestroys a window created with CreateWindowEx.

Window properties and state

FunctionDescription
GetWindowRectGets the window bounding rectangle in screen coordinates.
GetClientRectGets the client area rectangle.
GetWindowPlacementGets the show state and positions of a window.
GetWindowInfoGets window information including styles and borders.
IsWindowTests whether a handle is a valid window.
IsWindowEnabledTests whether a window accepts user input.
IsWindowVisibleTests whether a window is visible.
GetWindowLong / SetWindowLongGets or sets a 32-bit value in the window data.
GetWindowLongPtr (W) / SetWindowLongPtrGets or sets a pointer-sized value in the window data. Used for window styles and procedures.

Window position and layout

FunctionDescription
SetWindowPosSets the size, position, and Z-order of a window.
AdjustWindowRectExCalculates the required window size for a given client area size.
BeginDeferWindowPos / EndDeferWindowPosBatches multiple window position changes for performance.

Window hierarchy

FunctionDescription
GetActiveWindowReturns the active window on the calling thread.
GetTopWindowReturns the topmost child window.
GetWindowRetrieves a related window (next, previous, owner, child).
GetDesktopWindowReturns a handle to the desktop window.
FindWindowFinds a top-level window by class name or title.
WindowFromPointReturns the window at a given screen coordinate.
EnumChildWindowsEnumerates child windows of a parent.
EnumThreadWindowsEnumerates windows owned by a thread.

Window display

FunctionDescription
SetWindowRgnSets a window's visible region.
RedrawWindowRedraws a window or region.
InvalidateRectMarks a rectangle as needing repaint.
SetWindowDisplayAffinityControls whether a window can be captured by screen capture tools. Stub implementation.

System menu

FunctionDescription
GetSystemMenuReturns a handle to the window's system menu (the menu shown when clicking the window icon).

Focus and input

FunctionDescription
GetFocusReturns the window with keyboard focus.
SetForegroundWindowBrings a window to the foreground and gives it focus.
GetCapture / ReleaseCaptureGets or releases mouse capture.
GetKeyStateReturns the state of a virtual key (up, down, toggled).
GetCursorPosReturns the cursor position in screen coordinates.
GetMessagePos / GetMessageTimeReturns the cursor position and time of the last message.

Messages

FunctionDescription
SendMessageSends a message to a window and waits for processing. Limited message support.
PostMessagePosts a message to a window's message queue. Limited message support.
DefWindowProc (W)Provides default processing for messages not handled by a window procedure.
FormatMessageWFormats a system error message string.

Hooks

FunctionDescription
SetWindowsHookExInstalls a hook procedure. Limited hook types supported.
UnhookWindowsHookExRemoves a hook procedure.

Caret

FunctionDescription
CreateCaretCreates a caret (text cursor) for a window.
ShowCaret / HideCaretShows or hides the caret.
DestroyCaretDestroys the current caret.
SetCaretPosSets the caret position.
FunctionDescription
TrackPopupMenuExDisplays a shortcut menu at a specified location.
EnableMenuItemEnables, disables, or grays a menu item.

System information

FunctionDescription
GetSysColorReturns the current color of a display element (button face, window background, etc.).
SystemParametersInfo (W)Gets or sets system-wide parameters (scroll bar size, animation settings, etc.).
GetDoubleClickTimeReturns the maximum interval between two clicks for a double-click.
GetSystemMetricsReturns system metric values (screen size, icon size, scroll bar dimensions, etc.).
GetCaretBlinkTimeReturns the caret blink interval.

Clipboard

FunctionDescription
AddClipboardFormatListenerRegisters a window to receive clipboard change notifications.

gdi32.dll

Device contexts

FunctionDescription
GetDC / ReleaseDCGets or releases a device context for a window.
CreateCompatibleDC / DeleteDCCreates or deletes a memory device context.
GetDeviceCapsReturns device capabilities (DPI, color depth, etc.).

Drawing objects

FunctionDescription
CreateRectRgnCreates a rectangular region.
CreateRoundRectRgnCreates a rectangular region with rounded corners.
CreateRectRgnIndirectCreates a rectangular region from a RECT structure.
DeleteObjectDeletes a GDI object (region, brush, pen, etc.).
GetStockObjectReturns a handle to a predefined stock object.

Coordinate mapping

FunctionDescription
GetMapMode / SetMapModeGets or sets the mapping mode for a device context.
SetWindowExtEx / SetViewportExtExSets the window or viewport extents for coordinate mapping.
OffsetRectMoves a rectangle by a specified offset.

dwmapi.dll

FunctionDescription
DwmIsCompositionEnabledReturns whether desktop composition is enabled. Always returns true on non-Windows.
DwmExtendFrameIntoClientAreaExtends the window frame into the client area.
DwmGetWindowAttributeGets a DWM window attribute. Limited attribute support.
DwmSetWindowAttributeSets a DWM window attribute. Limited attribute support.

shcore.dll / Monitor APIs

FunctionDescription
MonitorFromPointReturns the monitor containing a point.
MonitorFromRectReturns the monitor with the largest intersection with a rectangle.
MonitorFromWindowReturns the monitor containing the largest part of a window.
GetMonitorInfoReturns the display area and work area of a monitor.
EnumDisplayMonitorsEnumerates display monitors.
GetDpiForMonitorReturns the DPI of a monitor.
GetDpiForWindowReturns the DPI for a window.
GetProcessDpiAwarenessReturns the DPI awareness setting for a process.

imm32.dll (Input Method Editor)

FunctionDescription
ImmCreateContext / ImmDestroyContextCreates or destroys an IME input context.
ImmGetContext / ImmReleaseContextGets or releases the IME context for a window.
ImmAssociateContextAssociates an IME context with a window.
ImmSetOpenStatus / ImmGetOpenStatusOpens or closes the IME, or queries the current state.
ImmNotifyIMESends a notification to the IME.
ImmGetPropertyReturns IME properties.
ImmGetCompositionString (W)Returns the composition string (the text being composed).
ImmSetCompositionFont (W)Sets the font used to display the composition string.
ImmConfigureIMEWOpens the IME configuration dialog.
ImmSetCompositionWindowSets the position of the composition window.
ImmSetCandidateWindowSets the position of the candidate list window.
ImmGetDefaultIMEWndReturns the default IME window handle.

kernel32.dll

FunctionDescription
GetCurrentThreadIdReturns the calling thread's ID.
GetModuleFileNameReturns the full path of a loaded module.
GetModuleHandle (W)Returns the handle of a loaded module by name.
LoadLibrary (W)Loads a DLL. Intercepted by the shim to redirect Win32 DLL loads.
LoadString (W)Loads a string resource from an executable.
CloseHandleCloses an object handle.
RtlGetVersionReturns the OS version. Returns emulated Windows version info on non-Windows.

File and memory mapping

FunctionDescription
CreateFileMappingCreates or opens a file mapping object.
MapViewOfFile / UnmapViewOfFileMaps or unmaps a view of a file mapping into the process address space.
FindFirstFile / FindNextFile / FindCloseEnumerates files in a directory.

Memory

FunctionDescription
RtlMoveMemoryCopies a block of memory.

shell32.dll

FunctionDescription
SHGetFileInfo (W)Returns information about a file (icon, display name, type).
ExtractIconEx (W)Extracts icons from an executable or DLL.

uxtheme.dll

FunctionDescription
IsThemeActiveReturns whether visual styles are active.
SetWindowThemeAttributeSets theme attributes on a window.

msctf.dll

FunctionDescription
TF_CreateThreadMgrCreates a Text Services Framework thread manager.