Question: Does anyone know if there is an API to get the current monitor state (on or off) in Windows (XP/Vista/2000/2003)?

All of my searches seem to indicate there is no real way of doing this. 

[This thread](http://www.promixis.com/forums/archive/index.php/t-1282.html) tries to use [GetDevicePowerState](http://msdn.microsoft.com/en-us/library/aa372690(VS.85).aspx) which according to Microsoft's docs does not work for display devices. 

In Vista I can listen to [GUID\_MONITOR\_POWER\_ON](http://msdn.microsoft.com/en-us/library/aa373195(VS.85).aspx) but I do not seem to get events when the monitor is turned off manually. 

In XP I can hook into `WM_SYSCOMMAND` `SC_MONITORPOWER`, looking for status 2. This only works for situations where the system triggers the power off. 

The WMI `Win32_DesktopMonitor` class does not seem to help out as well. 

**Edit**: Here is [a discussion](http://groups.google.com/group/comp.os.ms-windows.programmer.win32/browse_thread/thread/6d3e0a0828e68b89/d095095f5244bab4?lnk=gst&q=GetDevicePowerState++monitor#d095095f5244bab4) on comp.os.ms-windows.programmer.win32 indicating there is no reliable way of doing this. 

Anyone else have any other ideas?

Answer: 
In Windows XP or later you can use the IMSVidDevice Interface. 

See
<http://msdn.microsoft.com/en-us/library/dd376775(VS.85).aspx>

(not sure if this works in Sever 2003)
This is a really old post but if it can help someone, I have found a solution to detect a screen being available or not : the Connecting and Configuring Displays (CCD) API of Windows.

It's part of `User32.ddl` and the interesting functions are `GetDisplayConfigBufferSizes` and `QueryDisplayConfig`. It give us all informations that can be viewed in the Configuration Panel of windows.

In particular the `PathInfo` contains a `TargetInfo` property that have a `targetAvailable` flag. This flag seems to be correctly updated on all the configurations I have tried so far.

This allow you to know the state of every screens connected to the PC and set their configurations.

[Here a CCD wrapper for .Net](https://github.com/regueiro/CCDWrapper/tree/master/CCDWrapper)