I wanted to be able to turn on/off my monitors from 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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With