How to install (register) screensaver programmatically?
Asked
Active
Viewed 4,455 times
3
-
Well you install a program that installs the screensaver. – orlp Mar 12 '11 at 12:26
2 Answers
5
AFAIk there are two ways:
- Permanent registration by copying it to a location that windows searches, such as
System32. But don't hardcode "C:\Windows\System32". You need to query the system to find out where the system directory is. - Calling the
Installaction on the.scrfile, which results in temporary activation. But the screensaver will disappear once another has been selected and the dialog restarted.
But this is from Win95 times, so it's possibly outdated.
I see three ways to call install:
- ShellExecute(Ex) using the
installverb - Call
rundll32.exe desk.cpl,InstallScreenSaver %l - Load
desk.cplas library(LoadLibrary or by declaring an import forInstallScreenSaver) and then call theInstallScreenSavermethod with your own path as parameter.
CodesInChaos
- 106,488
- 23
- 218
- 262
-
2
-
1
-
-
The problem with the desk.cpl method is that it opens a configuration dialog. Not good if you are in an installer. I cannot seem to get 'install' to work in XP but maybe I'm doing it wrong. The only thing that works consistently for me is to right click on the file and select 'install' from the menu but this is not programmatic. Still looking for a proper solution. – jcoffland Oct 24 '12 at 23:33
-
@jcoffland Since the installation with that method is temporary, I recommend copying the screensaver to a directory where windows finds it. But the last time I touched screensavers was back on Win95, so I don't remember most details, and the recommended method might have changed since then too. – CodesInChaos Oct 25 '12 at 08:33
-
@user626528 You can create a `ProcessStartInfo` object and set the `Verb` property on it to "Install", then use it in `Process.Start()` – Owen Johnson Mar 25 '13 at 16:24
1
A walkthrough here -
http://www.desktopmanagementsoftware.org/creating-an-msi-package-for-a-screensaver
Miles
- 11
- 1