title: How to get HMONITOR information in MSDN Windows?
body: <p>What I require to do is pass a handle to the primary monitor to the <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/bb173068%28v=vs.85%29.aspx" rel="nofollow">DXGI_OUTPUT_DESC structure</a> in Windows so that the RECT of DesktopCoordinates has only the primary monitor dimensions even if multiple monitors are connected.</p>
  
  <p>Here is the structure of DXGI_OUTPUT_DESC:</p>
  
  <pre><code>typedef struct DXGI_OUTPUT_DESC {
    WCHAR              DeviceName[32];
    RECT               DesktopCoordinates;
    BOOL               AttachedToDesktop;
    DXGI_MODE_ROTATION Rotation;
    HMONITOR           Monitor;
  } DXGI_OUTPUT_DESC;
  </code></pre>
  
  <p>However I referred to almost all <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/dd144901%28v=vs.85%29.aspx" rel="nofollow">GetMonitorInfo</a> functions in the MSDN directory which have HMONITOR parameter but all are <em>In</em> and none of them return a Handle to the monitor. </p>
  
  <p>So basically my question is what function or command do I use so that a handle to the primary monitor is returned which then I can modify in the DXGI_OUTPUT_DESC in order to modify the RECT of DesktopCoordinates to match the dimensions of the primary monitor.</p>
  
  <p>This question is obviously for the case when there are multiple monitors connected to the system but I require the dimensions only of the primary monitor.</p>