WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Registry
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Basic Registry Info

Keywords: registry regedit 

Question:

Is there a decent book on regitry entries, or are you just hacking your way thru, until you find the right entries you are looking for?

Answer:

  1. I use PCMag's freeware InCtrl3 software to monitor Registry changes when I run something. If it is something I want to change the configuration or to automate the installation of, the report InCtrl3 gives tells me what keys are changed, added, deleted, etc.

  2. A very good book that is okay as a reference but really good as an entry into the registry is "The Windows 95 Registry" by John Woram, MIS:Press, isbn: 1-55828-494-X, http://www.mispress.com
Here are a couple more tools available to discover what's in the registry:

  1. TueakUI from Microsoft's PowerToys.
    
    http://www.microsoft.com/windows95/info/powertoys.htm  
    

  2. WinHacker 95 from Wedge Software is a utility that you can use to configure the hidden Windows 95 (and Windows NT 4.0 with version 2.0) settings. WinHacker 95 is THE Windows Shell Management Tool.
    
    http://www.wedgesoftware.com/wh95/index.html
    

    Many of the settings that change the way Windows 95 works and feels are hidden in the overwhelming registry, or in configuration files. WinHacker 95 give you a easy way to configure those settings through the GUI (graphical user interface)!

    Some features of WinHacker 95 2.0 are:

    • Ability to rename or change the icon of any shell folder (such as My Computer, Recycle Bin).
    • Add / Remove specific shell folders from My Computer or the Desktop. Ability to move your desktop directory, and other folders such as Favorites, etc
    • Show Windows Bitmaps as thumbnails in Explorer.
    • Scripting language to create 'plugins' that can modify the registry, INI files, etc.

Here are a couple of articles on the Windows Registry.

The July 1996 Issue of Windows Magazine had an article written by Karen Kenworthy on how to "Unlock the Registry's Secrets". Check it out at: http://winmag.com/library/1996/0796/07fa1001.htm#A1

Here's another article from:
Tandy Trower
July 13, 1995

No, this month's column doesn't concern sending in the registration card for the latest Microsoft product you bought. It's about using the registry in Windows 95 to make the most of integrating your application with the system.

You may be wondering why I cover this in a column dedicated to user interface (UI) design. My answer is: Your application's UI will be severely affected if you ignore the registry. Watz da "registry"?

The registry is a special repository supplied by the system that serves as a configuration database for user, application, and computer-specific information. For example, the system uses this information to determine which icons to display on the desktop and in folders.

The registry has a hierarchical structure; each node in the tree is a key. Each key can have a set of values. Each value entry is composed of three parts: the name of the key, its data type, and the value itself.

When your application is installed, information about it should be stored in the registry.Info can be added to the registry either by using registry APIs or by creating a registry (.REG) file and then using the Registry Editor. A registry file is essentially a text file containing entries following a specified format.

Registering state information Washington: capital Olympia; flower rhododendron; bird oops, wrong kind of state information. Ideally, when a user reopens an object (file), it returns to the state in which the user last left it. Windows 95 helps you support this important concept, called "persistence of state."

There are two major keys in the registry for this purpose: HKEY_LOCAL_MACHINE and HKEY_CURRENT_USER. Store machine-specific information under HKEY_LOCAL_MACHINE and user-specific information under HKEY_CURRENT_USER.

Under the Software subkey, you can add your own keys for storing information that you formerly stored in .INI files. Though the Windows 95 operating system supports these for backward compatibility, using .INI files is not recommended. The registry is more flexible and allows the system to track this information better should a user update or move your application's files.

You can also use the two major keys to restore your application's state. Let's say when the user starts up Windows, you'd like to restore any windows open at shutdown as the system does for folders. To do this when a user shuts down the system, design your application to store its state under its registered key entries and then create a value entry for the RunOnce subkey under HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion.

Use your application's name in defining the value name for the entry and assign it to an appropriate command-line string for your application. For example: WordPad Document 1 = C:\Program Files\ WordPad.exe Letter to Dr. Gui /Restore The precise syntax here is really up to you. When a user restarts Windows, the system will run your command string and the application can restore its state.

Finding the path

Rather than jam your application's files into Windows directories, you can now place them in a more logical location, and the system can still find them. For example, you register the path where you locate your executable (.EXE) files as well as dynamic-link library (DLL) files by using the AppPaths subkey under HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion. Add a subkey using your application executable filename and set its default value to the path for your .EXE file. Add an additional value named Path for this subkey, and set its value to the path of your DLLs. The system will automatically update the path for these entries if a user moves or renames the application's executable file using the standard system UI.

If you have a DLL that will be shared systemwide among many applications, you should place it in the System directory created by Windows and register its filename as a value for the SharedDLLs subkey.

What's your type?

The most important entries you supply for the registry are your application's file types. These tell the system which icon to display and which application to run when a user opens a specific data file. If a file type is not registered, the system substitutes a generic icon and lists its type as Unknown, with the result being that a user won't be able to double-click its icon to open it.

To register the file types supported by your application, include information under HKEY_CLASSES_ROOT, another major key in the registry. For each extension, you need to create an extension subkey and set its default value to an application identifier string (also known as the programmatic identifier, or Prog ID to you OLE jockeys). Then, using the same string, create another subkey and set its value to the type name (also known as the MainUserTypeName). The type name is the user-readable name of the file type (or class name). You'll typically want to include your company name, product name, and data type. As an option, you can also include a version number. For OLE purposes, you should also register a short type name. (See the OLE documentation for more details.)

Under this application identifier subkey, add a DefaultIcon subkey and set its value to the path of the file that contains the icon for the type. This can be an icon you include in the resources of your .EXE file or in a separate file, such as a .DLL, an .ICO, or a .BMP. If you use an .EXE file, you need to include the index value that corresponds to the icon within the file. A positive number represents the icon's position in the file. A negative number corresponds to the inverse of the resource ID number for the icon. The system always uses the first icon resource in an .EXE file to determine which icon to display for that executable file.

Design your application's file type icons to be related to, but distinctly different from, the application's icon. Include the following sizes: 16x16 (16 color), 32x32 (16 color), and 48x48 (256 color).

Yes, that's right, the system now supports a new, larger icon size, intended for high-performance, high-resolution machines. Also, all icon sizes can be supported in 256 colors. However, greater color depth also consumes more system resources. These sizes and color resolutions were designed to provide appropriate support across a wide variety of systems.

Adding commands

As a good container, the system automatically includes a number of commands for all types. These commands appear on the menus (drop-down and pop-up) of icons of all file types. For example, the system automatically provides Cut, Copy, Paste, Create Shortcut, Delete, Rename, and Properties commands.

However, you have to register other commands as appropriate, such as Open, Play, and Print, to activate the files of your type. To do so, add a Shell subkey under your application identifier subkey. Under it, register a subkey with the name of the operation, or verb, and set its value to the name you want to appear in menus.

The verb name itself should be a language-independent name of the command. However, its value must be localized for the specific version of Windows you install on. In U.S. and English versions, these entries may be the same; for example, Analyze = &Analyze. (The ampersand indicates the mnemonic access character that appears underlined in the menu.)

Then add a subkey named Command and set its value to the command-line string that should be executed to support that command (C:\Program Files\Stock Analysis\Stock.exe /A). You can also support dynamic data exchange (DDE) execution of the command by including a ddeexec subkey under the verb subkey and setting its value to a DDE command string. Under the ddeexec subkey, you'll need to include Application and Topic subkeys and set their values to the appropriate DDE application name and DDE topic name.

If files of your registered type are printed, you'll want to include Print verb entries. A Print verb subkey displays the Print command on the menu for the file. Including a PrintTo subkey allows the user to drag and drop the file onto a printer icon to have it printed. When supporting printing for your file types, consider providing a command-line switch that allows the file to be printed without bringing up the entire application interface. It is still perfectly appropriate to provide a message box indicating progress of the process, such as "Printing page m of n on printer name."

You can register multiple verbs for your file types to support different operations. To define their order in the menu, include the verb names, separated by commas, as the value for the Shell subkey. The first entry will be set as the default command for the object (which gets executed when the user double-clicks).

Because each verb entry can have a different command line, you can have different executable files handle different operations. You can even register commands for file types that aren't your own.

In the beginning...

Windows 95 has a nifty feature that allows the user to create new files of a specific type without having to invoke the application. For example, the desktop and folders support a New command that provides a list of the file types that can be created. To support this feature, you add an application identifier subkey under your extension subkey. (Don't confuse this with the application identifier subkey mentioned above. This one is UNDER the extension subkey.) Under this subkey add a ShellNew subkey. This subkey can be set to one of four values:

 
Value name   Result
Nullfile "" -Creates a null file of this type.
Dat binary data - Creates a new file containing the binary data.
Filename path - Creates a new file by copying the specified file.
Command filename - Executes the command, runs the file.
You can use the Command value to handle the file creation yourself.
And there's more...


Article ID:   W13712
Filename:   Basic Registry  Info and Utilities.txt
File Created: 2001:01:31:10:13:12
Last Updated: 2001:01:31:10:13:12