开发者

How to turn on/off the monitor(s)?

I wanted to be able to turn on/off my monitors fro开发者_JS百科m a Delphi script, from Windows XP to 7.

I have searched within the Delphi section on stackoverflow and didn't find the answer.

I also found many samples which doesn't work anymore on Windows 7 (only with XP).


I have successfully tested this on Windows XP and Windows 7:

const
  MONITOR_ON      = -1;
  MONITOR_OFF     =  2;
  MONITOR_STANDBY =  1;

To turn off the monitor:

  SendMessage(Application.Handle, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_OFF);

To turn on the monitor:

  SendMessage(Application.Handle, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_ON);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜