Providing Uninstall Functionality in an .inf File

Cc939923.chap_18(en-us,TechNet.10).gifCc939923.image(en-us,TechNet.10).gif

You can provide uninstall functionality in your .inf file by adding an installation section that removes the files, registry entries, and shortcuts and then adds your component to the list of programs that can be uninstalled from the Add/RemovePrograms dialog box in Control Panel. An example is included in the Inf folder of the IEAK Toolkit.

To add your component to the Add/Remove Programs dialog box, add the following registry information:

HKLM,SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\app-name,"DisplayName",,"display description"
HKLM,SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\app-name,"UninstallString",,"command-line description"

display description

The description string is displayed in the list box in the Add/Remove Programs dialog box.

command-line

The command line is executed when the user selects the component from the list box in the Add/Remove Programs dialog box. To execute a section in an .inf file, you can use the InstallHinfSection entry-point function in Setupx.dll.

The following examples show how to use AddReg entries to add "My Test Application" to the list box in the Add/Remove Programs dialog box and execute the [Remove_TestApp] installation section in Test.inf:

HKLM,SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Test,
"DisplayName",,"My Test Application" 

HKLM,SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Test,"UninstallString",,"RunDll setupx.dll,InstallHinfSection Remove_TestApp 4 test.inf"

Note Your installation code must copy the .inf file to the \Windows\Inf folder when your component is installed. This is the default location that is searched when the InstallHinfSection entry-point function is called.

Your code for uninstallation should remove the subkey that you created under the Uninstall registry key so that your optional component will no longer appear in the Add/Remove Programs list box after it has been uninstalled.

.