GetDpiForWindow function (winuser.h)

Returns the dots per inch (dpi) value for the specified window.

Syntax

UINT GetDpiForWindow(
  [in] HWND hwnd
);

Parameters

[in] hwnd

The window that you want to get information about.

Return value

The DPI for the window, which depends on the DPI_AWARENESS of the window. See the Remarks section for more information. An invalid hwnd value will result in a return value of 0.

Remarks

The following table indicates the return value of GetDpiForWindow based on the DPI_AWARENESS of the provided hwnd.

DPI_AWARENESS Return value
DPI_AWARENESS_UNAWARE The base value of DPI is which is set to 96 (defined as `USER_DEFAULT_SCREEN_DPI`)
DPI_AWARENESS_SYSTEM_AWARE The system DPI.
DPI_AWARENESS_PER_MONITOR_AWARE The DPI of the monitor where the window is located.

Examples

See Create a simple Direct2D application.

Requirements

Requirement Value
Minimum supported client Windows 10, version 1607 [desktop apps only]
Minimum supported server Windows Server 2016 [desktop apps only]
Target Platform Windows
Header winuser.h (include Windows.h)
Library User32.lib
DLL User32.dll

See also