Blake O'Hare .com

How to Make a Screensaver for Windows

So anyone's who's poked around their C:\Windows folder has probably seen those .scr files. So what is an .scr file? It's nothing more than a plain-old windows executable with a different file extension. That's right. Rename any .exe file to have a .scr extension and it will run like a screensaver. Play jokes on your co-workers by setting their screensaver to solitaire after 1 minute of idle-time.

Prankery aside, how do you make a screensaver? Well, obviously you make a .exe file using your favorite method. But what about the configuration screen? What about that little preview window you see in the screensaver chooser? How do you make those work?

These are all simply a protocol of command-line arguments sent to the executable.

If no command line argument is sent, this is assumed to be an attempt to access the screensaver configuration.

If the argument "/S" is sent, then this is telling the screensaver to start as normal.

As for the little preview window, a HWND handle is passed as a command line argument as an unsigned integer preceded with "/P". This handle is the preview window.

Of course any random .exe file will probably ignore this protocol and will just start as normal. But if you're actually making a screensaver, well, now you know what to do.

So in summary...

To launch:

YourScreensaver.exe /S

To configure:


To insert a preview to a window given a HWND:

YourScreensaver.exe /P HWND