Examples Delphi

On Tue, 17 Oct 2000 09:26:35 +0800, Kuo,Gordon wrote:
>Hi,
>
> Does anyone can tell me how to turn-on and turn-off the
>screen saver forcedly by the my program ?
>
Sure - you simply run the screensaver with the /s option.
ie something like
stFile := GetCurrentScreenSaver;
if FileExists(stFile) then
with LMDStarter1 do
begin
Defaultdir := gstWinSysPath;
command := stFile;
Parameters := '/S';
wait := false;
execute;
end;
The screensaver should turn itself off (ie on mouse move or something).
This will disable the screensaver (not the same as turning it off)
procedure TfrmLoadMain.mDisableScreensaverClick(Sender: TObject);
var tmp: integer;
begin
SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, Word(false), @tmp, 0);
end;
This will enable the screensaver
Procedure TfrmLoadMain.mEnableScreensaverClick(Sender: TObject);
var tmp: integer;
begin
SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, Word(true), @tmp, 0);
end;
To get the current screensaver
function GetCurrentScreenSaver: string;
var stFile, RPath: string;
RegObject: TStRegIni;
begin
result := '';
RPath := stDESKTOP;
RegObject := TStRegIni.Create(RICUser, false);
try
with RegObject do
begin
CurSubKey := RPath;
stFile := readString('SCRNSAVE.EXE', 'unknown');
end;
finally
RegObject.Free;
result := stFile;
end;
end; (* *)
This is using Turbopower, but the Delphi registry stuff is similar
-- Kerry Neighbour, kneighbour@simcomcity.com on 17/10/2000
ICQ #93143774
**************************************************************************
If you want to prevent the Screen Saver coming on while you perform
some other processing you can use Chami's code at this link:
http://www.chami.com/tips/delphi/121196D.html which handles the
Windows call to the screen saver. Very useful.
If you want to just invoke it see this link:
http://www.delphi3000.com/article.asp?id=534 This starts the current saver.
This method is better than just running the screen saver as the latter does
not properly invoke the password protection etc.
From: Kuo,Gordon [mailto:Gordon_Kuo@email.syscom.com.tw] wrote:
>Does anyone can tell me how to turn-on and turn-off the
>screen saver forcedly by the my program ?
Michael Darling
ROOM UNDERWRITING SYSTEMS LTD.
mailto:MXDarling@roomuw.co.uk