No screensaver during installation

From ISXKB

Revision as of 20:45, 6 February 2007 by Markus (Talk | contribs)
(diff) ←Older revision | Current revision (diff) | Newer revision→ (diff)
Jump to: navigation, search

During very long installations it could be annoying when a screen saver shows up. The following two functions allow to turn the screen saver off and back on again. Don't forget to include the global variable 'ScreenSaver' in your script.

var
	ScreenSaver : String;

procedure ScreenSaverOff;
begin
	// Remember the screen saver setting and delete the key afterwards.
	//  It will be restored before setup exists again.
	//  This will switch the screen saver off.
	ScreenSaver := '';
	if RegQueryStringValue(HKEY_CURRENT_USER, 'Control Panel\Desktop',
		'SCRNSAVE.EXE', ScreenSaver)
	then
	begin
		RegDeleteValue(HKEY_CURRENT_USER, 'Control Panel\Desktop', 'SCRNSAVE.EXE');
	end;

end;


procedure ScreenSaverOn;
begin
	if ScreenSaver <> '' then
	begin
		RegWriteStringValue(HKEY_CURRENT_USER, 'Control Panel\Desktop',
			'SCRNSAVE.EXE', ScreenSaver);
	end;

end;

The function to turn the screen saver off needs to be called from InitializeSetup (), and the one to turn it back on again from DeInitializeSetup ().

function InitializeSetup(): Boolean;
begin
	// Turn the screen saver off.
	ScreenSaverOff;
end;

procedure DeinitializeSetup ();
begin
	// Switch the screen saver back on.
	ScreenSaverOn;
end;

Personal tools
Ads: