Share via


GetDpiForMonitor function

Queries the specified monitor for the dots per inch (dpi) horizontal and vertical values.

Syntax

STDAPI GetDpiForMonitor(
  _In_   HMONITOR hmonitor,
  _In_   MONITOR_DPI_TYPE dpiType,
  _Out_  UINT *dpiX,
  _Out_  UINT *dpiY
);

Parameters

  • hmonitor [in]
    Handle of the monitor being queried.

  • dpiType [in]
    The type of dpi being queried.

    Value Meaning
    MDT_EFFECTIVE_DPI 0

    Effective dpi that incorporates accessibility overrides and matches what Desktop Window Manage (DWM) uses to scale desktop applications.

    MDT_ANGULAR_DPI 1

    Dpi that ensures rendering at a compliant angular resolution on the screen, without incorporating accessibility overrides.

    MDT_RAW_DPI 2

    Linear dpi of the screen as measured on the screen itself.

    MDT_DEFAULT MDT_EFFECTIVE_DPI

    The default value used if no other value is set.

     

  • dpiX [out]
    The value of the dpi along the X axis. This value always refers to the horizontal edge, even when the screen is rotated.

  • dpiY [out]
    The value of the dpi along the Y axis. This value always refers to the vertical edge, even when the screen is rotated.

Return value

If this function succeeds (the function successfully returns the X and Y dpi values for the specified monitor), it returns S_OK. Otherwise, it returns an HRESULT error code, including the following:

Return code Description
E_INVALIDARG

The handle, DPI type, or pointers passed in are not valid.

 

Remarks

When the dpiType parameter is MDT_Effective_DPI, the returned dpi value includes any changes that the user made to the dpi by using the desktop scaling override slider control in Control Panel.

When the dpiType parameter is MDT_Angular_DPI or MDT_Raw_DPI, the returned dpi value does not include any changes that the user made to the dpi by using the desktop scaling override slider control in Control Panel.

For more information about dpi settings in Control Panel, see the Writing dpi-Aware Desktop Applications in Windows 8.1 white paper.

Requirements

Minimum supported client

Windows 8.1 [desktop apps only]

Minimum supported server

Windows Server 2012 R2 [desktop apps only]

Header

ShellScalingAPI.h

Library

Shcore.lib

DLL

Shcore.dll

See also

GetProcessDpiAwareness

SetProcessDpiAwareness

 

 

Build date: 1/13/2014