We help IT Professionals succeed at work.

Delphi Programming question

mobius asked
Medium Priority
Last Modified: 2010-04-06
Watch Question

Hi Catherine,

Here is a (short) explanation:

Screensavers are executed by Windows in two ways: either when an interval of inactivity causes Windows to execute the screensaver, or when it is being configured in Control Panel. In Windows 95, screensavers have four modes of execution and these are selected by command line parameters:

1. Preview mode.

When you select the saver in Control Panel, Windows sends two parameters, /p HWND, to select preview mode and to pass the handle of the preview window.

2. Configuration mode.

When you click Settings, Windows sends a parameter, /c, to select configuration mode. The saver responds by presenting a configuration dialogue.

3. Password mode.

When you click to change the password, Windows sends two parameters, /a HWND, to select password mode and to pass the handle of the parent window for your password dialogue.

4. Start mode.

When you click Preview, or when the saver is called for real, Windows sends a parameter, /s, to select start mode.

The application should check the command line parameters to see whether it should draw in the preview window or present a configuration dialogue. Screensaver security is treated in different ways by Windows 95 and Windows NT. Under Windows 95, most screensavers call the Windows Master Password Router. This is a DLL called MPR.DLL which exports password functions like PwdChangePassword. They are usually called via another DLL, PASSWORD.CPL, which works as an extension to the Control Panel. Neither of these libraries are fully documented in the Windows SDK, but some have worked out how to use them. The alternative is to implement your own password checking and throw up your own password dialogue when the saver is called in password mode. Windows NT is different. Passwords for NT screensavers are the same as those used for logging on to Windows. The Control Panel marks a registry entry to indicate a secure screensaver:
Finally, there is the matter of the description line. Confusingly, Microsoft has devised three ways of identifying this. Originally, it was the module description entry, which had to be of the form
“SCRNSAVE : My Description.”
Under Windows 95 and NT it became a resource string with an ID of 1 — and yes, Delphi can use standard Windows resources. This is the documented way; but actually, Windows 95 does not use it. It simply uses the long filename, less the .SCR extension. By the way, Windows will find any screensaver, identified by a .SCR extension, in the Windows or System folders, so at least installation is easy.

I hope this will help you and that your problems will be solved !

See ya,



Thanks Cyberwolf.

I'm not rejecting your reply because I don't like it (which I do, I think it's very good indeed!), but simply to keep the question 'open'. BTW, how long is the long explanation?

I didn't know about the other parameter options, so now I can build them into the main form, but as my savers work by having a full-screen-size form on which everything is drawn, how can this be re-directed to the handle of the preview window so the output appears there? I admit this isn too great an issue for me as I'm more interested in getting the savers to work properly to begin with, but it would be nice

My final question: what is the resource string you're referring to in the last paragraph and where is it located in the .dpr/.pas?


There is a good example at:

It might help.

Hi Catherine,

This time a very very short explanation:

To use the hwnd parameter for the preview, I recommend not to use a TForm. It's a large dcu (150 K) entirely linked to your executable. If you use the windows API, everything you need will be done with less than 15 K. (Instead of 150K !!)

Using the windows API seems a bit difficult in the beginning, but I can tell you that it's easier than it sounds !

Of course, you can use some trick to overcome this problem. You can simply paint a static bitmap on the small preview window. (Just retrieve the hdc and associate it with a TCanvas handle. Then simply draw a bitmap on it as you usualy do !) The use of a TForm for the full screen window will no longer be a problem.

Ok, now your question about the resource string.

Each delphi file is linked with a file that has the same name as the original but with the extension turned into 'res'. (Ex.:main.pas main.res) 'Res' stands for resource. However, these resource files are already compiled. (They can hold bitmaps,videos,version information,... and also strings !)

You can also create your own resource files. (.rc files that you compile with brcc32.exe located in the bin dir) You can use a simple text editor such as notepad to create them. Here is an example of what you should need:


     1,"Replace this in order to get a decent name for your screensaver"

generating myscreensavercustomresource.res --> brcc32 -r myscreensavercustomresource.rc

linking with delphi project --> add the following line to your dpr : {$R myscreensavercustomresource.res}

(I don't want you to know how the long explanation can be ... so I won't cover this more in detail, but if you want some additional information on how to write rc files, simply ask and I'll be there for you ...)

See ya,


Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts


Thanks Cyberwolf.
As you probably realised I'm still quite new to all this, and yes, everything I've done so far is on a TForm. The resource string description has gone straight over my head at the moment, but it will probably make sense once I've tried it.
I'm still having trouble with the /c option, as even though it's parsed correctly and works as a parameter from file manager to display the saver's controls, as soon as the .scr file is accessed by desktop\screensavers\configure, all that happens is the screen blinks. There's obviously a fundamental flaw in my program somewhere, as everyone else's work OK, but you've been very helpful and I don't want to impose too much.
Thanks again for the help,
Hi Catherine,

It was a pleasure to me to help you. If you want, I have some examples of screensavers and a help file which explains screen savers in detail. I will send them to your mailbox if you give me your e-mail address. If you want I can also explain you how to deal with resources more in detail ?

See ya,

CyberWolf (cyberwolf_cool@hotmail.com)

P.S.:Please, send me a copy of your screensaver when it's finished !
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.