转帖一段:
//NumenMeName是屏幕保护程序路径
if FileExists(NumenMeName) then
begin
Reg:=Tregistry.Create;
Reg.RootKey:=HKey_Current_User;
Reg.OpenKey('Control Panel/Desktop',False);
if UpperCase(Reg.ReadString('SCRNSAVE.EXE'))<>UpperCase(NumenMeName) then
if MessageDlg('NumenMe现在不是默认屏幕保护程序,'+#13#10+
'你要把它设置成默认屏幕保护程序吗',
mtConfirmation, [mbYes, mbNo], 0) = mrYes then
begin
Reg.WriteString('SCRNSAVE.EXE',NumenMeName);
SystemParametersInfo(SPI_SETDESKWALLPAPER,0,nil,SPIF_SendChange);
end;
Reg.CloseKey;
Reg.Free
NT的默认屏保路径是放在注册表的HKEY_CURRENT_USER/CONTROL PANEL/DESKTOP/SCRNSAVE.EXE
下;而Win98的是放在System.ini文件的[boot]下的,在[boot]下加入 SCRNSAVE.EXE=路径 ,
就可以了
var
s:array[0..200] of char;
begin
GetSystemDirectory(s,190);
ShellExecute(handle, pchar('open'), pchar(StrPas(s)+'/星空模拟.scr'), pchar(''), pchar(''), SW_SHOWNORMAL);
end;