If you want to run default system screensaver from your application, it’s really easy. Just few lines of code. Here’s how to do it…
Sometimes it can be useful to run a default screensaver from your application. And doing it is simple. Here is short example made as an OnClick event.
procedure TForm1.Button1Click(Sender: TObject);
var b : boolean;
begin
if not SystemParametersInfo(SPI_GETSCREENSAVEACTIVE, 0, @b, 0) then exit;
if not b then exit;
PostMessage(GetDesktopWindow, WM_SYSCOMMAND, SC_SCREENSAVE, 0);
end;
Running screensaver can be deactivated usual way, just move your mouse or press any key.