|
Lennie's Weekly Delphi Tip:
2000 Ref. 14
The following function will set the Screen Saver's time-out.
This is the amount of time, in minutes, that the system must be idle
before the screen saver activates.
function SetScreenSaverTimeOut(Minutes : integer) : boolean;
var
Sec : integer;
begin
if (Minutes in [1..60]) then
begin
Sec := Minutes * 60; // Convert minutes
into seconds.
Result := SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT,
Sec, nil, 0);
end
else
Result := False;
end;
The Minutes parameter must be between the range of 1 to 60 minutes and is the amount of time, in minutes, that the time-out is set to.
If the function succeeds it'll return TRUE, else a value of FALSE are
returned.
The time-out is set, even if the Screen Saver is not enabled.
You can also use the GetScreenSaverTimeOut function (Ref. 13) to return
the default Screen Saver time-out before you set the time-out. This way
you can restore the previous time-out, if needed.