• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1155
  • Last Modified:

How to get the power state of a monitor?(working, low power or soft off)

Maybe this API function can do, but I don't know how to get the handle of the monitor.
Could you help me?

BOOL GetDevicePowerState(  HANDLE hDevice,  BOOL* pfOn);
Parameters
hDevice
[in] Handle to an object on the device, such as a file or socket, or a handle to the device itself.
pfOn
[out] Pointer to the variable that receives the power state. This value is TRUE if the device is in the working state. Otherwise, it is FALSE.
0
unniuX
Asked:
unniuX
  • 2
  • 2
1 Solution
 
Svetlin_PanayotovCommented:
http://www.codeproject.com/gdi/multimon.asp?print=true
Here's a MFC class that contains the info you need - or at least how to get monitor's name.After retrieving it you can call CreateFile to get the handle.
Svetlin
0
 
unniuXAuthor Commented:
I tried to use CreatedFile("\\\\.\\DISPLAY1",....) to get the monitor's handle , but it returned 5 (Access is denied). How to do?
0
 
Svetlin_PanayotovCommented:
Do you use Win NT (XP,2000,NT4)?
If you do - make sure you have admin rights.
Svetlin
0
 
unniuXAuthor Commented:
Thanks, Svethlin. But there's no way to get the handle of a monitor, because "the DISPLAY symbolic link is off-limits to everyone, including users with administrator rights. The premise behind this is that the Windows NT kernel should be the only one that has control of the video display. "

refer to : http://www.eu.microsoft.com/msj/0398/driver.aspx

I'v given up on it. Bye!
 
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now