The Windows Programs in the Registry

Let’s take a look at one fine, upstanding citizen, and see whether you can learn anything about registry duties. If any program ought to be well-behaved under Windows 95, it’s WordPad. Figure 10-6 on page 603 shows an abbreviated version of Word­Pad’s registry entries on my machine, and the following list provides some explanation.

You have two types of registry settings: document and application. None of the sample programs in this book create their own document types, but most programs in real life do. About document types, I’ll say only that you should study the Windows interface guidelines and do the right thing. If you can write one item to the registry, you can write anything. Let’s concentrate on the application settings. The most common ones—those holding permanent program
settings—are handled for you by GetSetting, GetAllSettings, SaveSetting, and DeleteSetting.

You’ll find a small difference between the recommended settings location (followed by WordPad) and the location that is used by Visual Basic programs. The Windows interface guidelines recommend that the settings be placed under a CompanyName branch in the Software branch of HKEY_CURRENT_USER. Visual Basic settings are placed in a branch called VB and VBA Program Settings. So if your application name is the same as someone else’s Visual Basic program name, your settings could conflict with theirs. Another possibility is that multiple users might log on to the same machine. If you want settings to apply to all users of a machine rather than to the current user only, you should save the settings in HKEY_LOCAL_MACHINE. If you have any doubts about Visual Basic’s default location for settings, you should write your own registry functions to put program settings where you want them.

Figure 10-6. WordPad registry entries.

For some reason, registry editors tend to be crude and ugly. The Windows 95 editor is a step in the right direction, but it still has a long way to go to meet my user interface standards. It should be as easy to use as the Windows Explorer, and it should provide a good way to switch between related entries. So what’s the problem? All you need is a tree view on the left, a list view on the right, a toolbar, a status bar, and a few menu items. No problem.