Platform SDK: Installing Applications/Setup

Removing an Application

Your installation program can direct the Add/Remove Programs application in Control Panel to list your application as an application that can be "automatically removed."

If you use the installer, there is no need to ensure that your application can be easily uninstalled. The installer has enough information about your application that it can uninstall it without an uninstall application.

If you do not use the installer, you can present an uninstall program by adding entries to the following registry key:

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\application-name

Note that application-name may not exceed 63 characters. You can use a GUID (38 characters long) to ensure that your key name will be unique.

The entries are as follows:

DisplayName=product-name
UninstallString=full-path-to-program command-line-parameters

Add/Remove Programs displays the product name specified by the DisplayName value in its list of applications that can be removed. Windows uses the value specified by the UninstallString value to start the uninstall program to carry out the removal of the application. This string needs to completely specify the command-line parameters needed to execute the uninstall program and remove the application. A full path is required. Both the DisplayName and UninstallString values must be complete, or Add/Remove Programs will not list the application.

Windows needs to know when the removal of the application is done, so it requires the UninstallString value to specify the uninstall program that actually carries out the removal. A batch file or other program that starts the removal program should not be specified.

The registry locations are defined as constants for C programmers in the REGSTR.H header file. Descriptions of the macros follow.

REGSTR_PATH_UNINSTALL Path to uninstall branch
REGSTR_VAL_UNINSTALLER_DISPLAYNAME DisplayName
REGSTR_VAL_UNINSTALLER_COMMANDLINE UninstallString

The uninstall program must display a user interface that informs the user that the removal process is taking place. Your uninstall program should provide a silent option that allows the user to run it remotely. The uninstall program should also display clear and helpful messages for any errors it encounters during the removal of the application. Windows will only detect and report a failure to start the uninstall program.

An uninstall program should complete the following steps: