开发者

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

开发者 https://www.devze.com 2023-04-02 02:13 出处:网络
I wanted to be able to turn on/off my monitors fro开发者_JS百科m a Delphi script, from Windows XP to 7.

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

精彩评论

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