title: Is there any way to detect the monitor state in Windows (on or off)?
body: <p>Does anyone know if there is an API to get the current monitor state (on or off) in Windows (XP/Vista/2000/2003)?</p>
  
  <p>All of my searches seem to indicate there is no real way of doing this. </p>
  
  <p><a href="http://www.promixis.com/forums/archive/index.php/t-1282.html" rel="noreferrer">This thread</a> tries to use <a href="http://msdn.microsoft.com/en-us/library/aa372690(VS.85).aspx" rel="noreferrer">GetDevicePowerState</a> which according to Microsoft's docs does not work for display devices. </p>
  
  <p>In Vista I can listen to <a href="http://msdn.microsoft.com/en-us/library/aa373195(VS.85).aspx" rel="noreferrer">GUID_MONITOR_POWER_ON</a> but I do not seem to get events when the monitor is turned off manually. </p>
  
  <p>In XP I can hook into <code>WM_SYSCOMMAND</code> <code>SC_MONITORPOWER</code>, looking for status 2. This only works for situations where the system triggers the power off. </p>
  
  <p>The WMI <code>Win32_DesktopMonitor</code> class does not seem to help out as well. </p>
  
  <p><strong>Edit</strong>: Here is <a href="http://groups.google.com/group/comp.os.ms-windows.programmer.win32/browse_thread/thread/6d3e0a0828e68b89/d095095f5244bab4?lnk=gst&amp;q=GetDevicePowerState++monitor#d095095f5244bab4" rel="noreferrer">a discussion</a> on comp.os.ms-windows.programmer.win32 indicating there is no reliable way of doing this. </p>
  
  <p>Anyone else have any other ideas? </p>