GetDpiForWindow function

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

Syntax

UINT GetDpiForWindow(
  HWND hwnd
);

Parameters

hwnd

The window 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 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 96
DPI_AWARENESS_SYSTEM_AWARE The system DPI.
DPI_AWARENESS_PER_MONITOR_AWARE The DPI of the monitor where the window is located.

Requirements

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

See Also

DPI_AWARENESS