Condividi tramite


Funzione GetPhysicalMonitorsFromHMONITOR (physicalmonitorenumerationapi.h)

Recupera i monitor fisici associati a un handle di monitoraggio HMONITOR .

Sintassi

_BOOL GetPhysicalMonitorsFromHMONITOR(
  [in]  HMONITOR           hMonitor,
  [in]  DWORD              dwPhysicalMonitorArraySize,
  [out] LPPHYSICAL_MONITOR pPhysicalMonitorArray
);

Parametri

[in] hMonitor

Handle di monitoraggio. Gli handle di monitoraggio vengono restituiti da diverse funzioni di monitoraggio dello schermo, tra cui EnumDisplayMonitors e MonitorFromWindow, che fanno parte dell'interfaccia del dispositivo grafico (GDI).

[in] dwPhysicalMonitorArraySize

Numero di elementi in pPhysicalMonitorArray. Per ottenere le dimensioni necessarie della matrice, chiamare GetNumberOfPhysicalMonitorsFromHMONITOR.

[out] pPhysicalMonitorArray

Puntatore a una matrice di strutture PHYSICAL_MONITOR . Il chiamante deve allocare la matrice.

Valore restituito

Se la funzione ha esito positivo, il valore restituito è TRUE. Se la funzione ha esito negativo, il valore restituito è FALSE. Per informazioni dettagliate sull'errore, chiamare GetLastError.

Commenti

Un singolo handle HMONITOR può essere associato a più monitor fisici. Questa funzione restituisce un handle e una descrizione di testo per ogni monitor fisico.

Al termine dell'uso degli handle di monitoraggio, chiuderli passando la matrice pPhysicalMonitorArray alla funzione DestroyPhysicalMonitors .

Esempio


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);
    }
}

Requisiti

Requisito Valore
Client minimo supportato Windows Vista [solo app desktop]
Server minimo supportato Windows Server 2008 [solo app desktop]
Piattaforma di destinazione Windows
Intestazione physicalmonitorenumerationapi.h
Libreria Dxva2.lib
DLL Dxva2.dll

Vedi anche

Monitorare le funzioni di configurazione