function ScreenSaver(SaverName: string): boolean;
begin
if (not fileexists(SaverName))
or (extractfileext(ansilowercase(SaverName)) <> '.scr')
then begin
result := false;
exit;
end;
result :=
shellexecute(application.handle, 'open', 'rundll32.exe',
pchar('desk.cpl,InstallScreenSaver "' + SaverName + '"'), nil, sw_show) > 32;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if not ScreenSaver('c:\windows\system\natur.scr')
then showmessage('Fehler');
end;