none
using "Monitor Configuration Functions" (monitor handle error) RRS feed

  • 질문

  • in the following code...

    I can't get a physical monitor handle.. it's always "0"

    (but description is ok )

     

    how can I get it?

    Thanks~!!

    ------------------------------------------------------------

    #include "stdio.h"
    #include "HighLevelMonitorConfigurationAPI.h"

     

    int main(void)
    {

     HWND hWnd = GetDesktopWindow();
     HMONITOR hMonitor = NULL;
     DWORD cPhysicalMonitors = 0;
     LPPHYSICAL_MONITOR pPhysicalMonitors = NULL;

     BOOL bGetNumberOfPhysicalMonitorsFromHMONITOR = FALSE;
     BOOL bDestroyPhysicalMonitors = FALSE;
     BOOL bGetPhysicalMonitorsFromHMONITOR = FALSE;

     

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

     

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

     

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

     

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

    /*

    about "pPhysicalMonitors"...
    1) Handle to a physical monitor is always "0"
    2) description is ok like "pnp monitor"

    */

     

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

     

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

     return 0;
    };

    2010년 6월 16일 수요일 오전 8:51