Platform SDK: Installing Applications/Setup

Adding Entries to the Registry

Your installation program should add information about your application to the registry. The installer provides an easy way to make the necessary registry entries. In particular, you should always add the following entries.

HKEY_LOCAL_MACHINE\SOFTWARE\CompanyName\ProductName\Version
Stores information pertaining to this particular copy of the application.
HKEY_CURRENT_USER\SOFTWARE
Stores user-specific preferences. This is information that application vendors used to store in the WIN.INI file. For example Microsoft Word might store the fact that a user wants the automatic save feature turned off here.

Your installation program should always add application-specific paths to the registry for your application. If your installation program registers a path, Windows sets the PATH environment to be the registered path when it starts your application. Your program sets the path in the HKEY_LOCAL_MACHINE root under the \SOFTWARE\Microsoft\Windows\CurrentVersion\AppPaths key (using the REGSTR_PATH_APPPATHS macro). Your installation program must create a new key having the same name as your application's executable file. Under this new key, it creates the Path value name and assigns it a path using the same format as expected by the PATH environment variable.

The following example shows application-specific paths for both Windows® Excel, Excel.Exe, and My Wizzy Application.Exe.

HKEY_LOCAL_MACHINE
  SOFTWARE\Microsoft\Windows\CurrentVersion\AppPaths
    Excel.Exe 
      Default=D:\Program Files\MS Office\Excel\Excel.Exe
      Path= D:\Program Files\MS Office\Excel\Excel.Exe;D:\Program 
          Files\Common Files\MS Office;

    My Wizzy App.Exe
         Default=d:\Program Files\My Wizzy Application\My Wizzy
             Application.Exe
         Path= D:\Program Files\My Wizzy Application;D:\Program Files\My
             Wizzy Application\Application Extensions;
 

In the preceding example, the Default value specifies the full path to the corresponding executable file. This value is typically used by Windows in the Start Run command. If the user types the name of your application but Windows fails to find it in the current path, Windows uses this value to locate and start your application.

If you use the installer you should not try to keep track of shared DLLs. The installer keeps track of them for you. However, if you do not use the installer, your application must keep track of its use of shared DLLs itself. When installing an application that uses shared DLLs, it should increment the usage counter for the DLL in the registry. When removing an application, it should decrement the usage counter. If the result is zero, the user should be given the option of deleting the DLL. The user should be warned that other applications may actually need the DLL and will not work if it is missing. The following example shows the general format for usage counters in the registry.

\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SharedDLLs
    C:\Program Files\Common Files\System\vbrun300.DLL=3