Bagikan melalui


Fungsi GetPhysicalMonitorsFromHMONITOR (physicalmonitorenumerationapi.h)

Mengambil monitor fisik yang terkait dengan handel monitor HMONITOR .

Sintaks

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

Parameter

[in] hMonitor

Handel monitor. Handel monitor dikembalikan oleh beberapa fungsi Monitor Beberapa Tampilan, termasuk EnumDisplayMonitors dan MonitorFromWindow, yang merupakan bagian dari antarmuka perangkat grafis (GDI).

[in] dwPhysicalMonitorArraySize

Jumlah elemen dalam pPhysicalMonitorArray. Untuk mendapatkan ukuran array yang diperlukan, panggil GetNumberOfPhysicalMonitorsFromHMONITOR.

[out] pPhysicalMonitorArray

Penunjuk ke array struktur PHYSICAL_MONITOR . Penelepon harus mengalokasikan array.

Nilai kembali

Jika fungsi berhasil, nilai yang dikembalikan adalah TRUE. Jika fungsi gagal, nilai yang dikembalikan adalah FALSE. Untuk mendapatkan informasi kesalahan yang diperluas, hubungi GetLastError.

Keterangan

Satu handel HMONITOR dapat dikaitkan dengan lebih dari satu monitor fisik. Fungsi ini mengembalikan handel dan deskripsi teks untuk setiap monitor fisik.

Ketika Anda selesai menggunakan handel monitor, tutup dengan meneruskan array pPhysicalMonitorArray ke fungsi DestroyPhysicalMonitors .

Contoh


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

Persyaratan

Persyaratan Nilai
Klien minimum yang didukung Windows Vista [hanya aplikasi desktop]
Server minimum yang didukung Windows Server 2008 [hanya aplikasi desktop]
Target Platform Windows
Header physicalmonitorenumerationapi.h
Pustaka Dxva2.lib
DLL Dxva2.dll

Lihat juga

Memantau Fungsi Konfigurasi