title: EnumDisplayDevices function not working for me
body: <p>I'm trying to get info on my monitors programmatically.  The content of the loops is not important right now, they just contain debug statements that will be printed when the loop condition is satisfied.  Right now, the outer loop code executes three times and the inner loop code is never accessed, meaning the while condition of the (inner) loop is never true, meaning that call fails.</p>
  
  <p>My problem here is that the Windows API says, regarding this function: </p>
  
  <blockquote>
    <p>To obtain information on a display monitor, first call EnumDisplayDevices with lpDevice >set to NULL. Then call EnumDisplayDevices with lpDevice set to DISPLAY_DEVICE.DeviceName >from the first call to EnumDisplayDevices and with iDevNum set to zero. Then >DISPLAY_DEVICE.DeviceString is the monitor name.</p>
  </blockquote>
  
  <p>...but even after doing exactly what it says, the second EnumDisplayDevices call always fails?  Any insight???</p>
  
  <p>Also I'm doing this as a service level application on both windows xp and windows 7 and getting the same results.  When I try to print out dd.DeviceName, it gives me an address (for example: 0x12cfa4), but this  must be what the function is expecting on the second call as MSDN says just pass in your display device pointer and append .DeviceName to it...</p>
  
  <p>C++ (using Qt), Windows API/MSDN calls are used.</p>
  
  <pre><code>    DISPLAY_DEVICE dd;
  
      dd.cb = sizeof(DISPLAY_DEVICE);
  
      DWORD deviceNum = 0;
      while( EnumDisplayDevices(NULL, deviceNum, &amp;dd, 0) ){
          qWarning() &lt;&lt; "We've entered the outer loop.";
  
          while( EnumDisplayDevices(dd.DeviceName, 0, &amp;dd, 0)){
              qWarning() &lt;&lt; "We've entered the inner loop.";
          }
  
          deviceNum++;
      }
  </code></pre>