Skip to content

Latest commit

 

History

History
128 lines (95 loc) · 4.4 KB

nf-physicalmonitorenumerationapi-getphysicalmonitorsfromhmonitor.md

File metadata and controls

128 lines (95 loc) · 4.4 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:physicalmonitorenumerationapi.GetPhysicalMonitorsFromHMONITOR
GetPhysicalMonitorsFromHMONITOR function (physicalmonitorenumerationapi.h)
Retrieves the physical monitors associated with an HMONITOR monitor handle.
GetPhysicalMonitorsFromHMONITOR
GetPhysicalMonitorsFromHMONITOR function [Monitor Configuration]
monitor.getphysicalmonitorsfromhmonitor
physicalmonitorenumerationapi/GetPhysicalMonitorsFromHMONITOR
monitor\getphysicalmonitorsfromhmonitor.htm
Monitor
f2ac8a6a-3be9-4155-ad13-c256b96da792
12/05/2018
GetPhysicalMonitorsFromHMONITOR, GetPhysicalMonitorsFromHMONITOR function [Monitor Configuration], monitor.getphysicalmonitorsfromhmonitor, physicalmonitorenumerationapi/GetPhysicalMonitorsFromHMONITOR
physicalmonitorenumerationapi.h
Windows
Windows Vista [desktop apps only]
Windows Server 2008 [desktop apps only]
Dxva2.lib
Dxva2.dll
Windows
19H1
GetPhysicalMonitorsFromHMONITOR
physicalmonitorenumerationapi/GetPhysicalMonitorsFromHMONITOR
c++
APIRef
kbSyntax
DllExport
dxva2.dll
GetPhysicalMonitorsFromHMONITOR

GetPhysicalMonitorsFromHMONITOR function

-description

Retrieves the physical monitors associated with an HMONITOR monitor handle.

-parameters

-param hMonitor [in]

A monitor handle. Monitor handles are returned by several Multiple Display Monitor functions, including EnumDisplayMonitors and MonitorFromWindow, which are part of the graphics device interface (GDI).

-param dwPhysicalMonitorArraySize [in]

Number of elements in pPhysicalMonitorArray. To get the required size of the array, call GetNumberOfPhysicalMonitorsFromHMONITOR.

-param pPhysicalMonitorArray [out]

Pointer to an array of PHYSICAL_MONITOR structures. The caller must allocate the array.

-returns

If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. To get extended error information, call GetLastError.

-remarks

A single HMONITOR handle can be associated with more than one physical monitor. This function returns a handle and a text description for each physical monitor.

When you are done using the monitor handles, close them by passing the pPhysicalMonitorArray array to the DestroyPhysicalMonitors function.

Examples

HMONITOR hMonitor = NULL;
DWORD cPhysicalMonitors;
LPPHYSICAL_MONITOR pPhysicalMonitors = NULL;

// Get the monitor handle.
hMonitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTOPRIMARY);

// Get the number of physical monitors.
BOOL bSuccess = GetNumberOfPhysicalMonitorsFromHMONITOR(
  hMonitor, 
  &cPhysicalMonitors
   );

if (bSuccess)
{
    // Allocate the array of PHYSICAL_MONITOR structures.
    pPhysicalMonitors = (LPPHYSICAL_MONITOR)malloc(
        cPhysicalMonitors* sizeof(PHYSICAL_MONITOR));

    if (pPhysicalMonitors != NULL)
    {
        // Get the array.
        bSuccess = GetPhysicalMonitorsFromHMONITOR(
            hMonitor, cPhysicalMonitors, pPhysicalMonitors);

       // Use the monitor handles (not shown).

        // Close the monitor handles.
        bSuccess = DestroyPhysicalMonitors(
            cPhysicalMonitors, 
            pPhysicalMonitors);

        // Free the array.
        free(pPhysicalMonitors);
    }
}

-see-also

Monitor Configuration Functions