HOWTO: Install Optional Components from 32-Bit Application Co

ID: Q194640

The information in this article applies to:

SUMMARY

After you install Windows 95, you might need to add one or more of the Windows 95 optional components. For example, "Games" is a Windows 95 optional component. This type of installation, which occurs after Windows 95 setup.exe initially installs Windows 95, is called maintenance-mode setup. Typically, you initiate maintenance-mode setup from the Windows 95 user interface by clicking Add/Remove Programs in the Control Panel. However, there is an alternative method available to vendors and suppliers of the optional software component, namely, they can install the optional component using a CreateProcess call in a 32-bit application.

MORE INFORMATION

NOTE: The CreateProcess method for installing an optional component described below must only be used in 32-bit applications.

To install an optional component from a 32-bit application, use a combination of the methods described below.

Checking the Registry

First, check the registry to see if the optional component is currently installed (or look for the files). The registry key location for the information about all the currently installed optional components is:

   HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SETUP\ 
   OptionalComponents

There are values under this key that point to subkeys, and each subkey contains information on the optional components installed, as well as information needed to install a new optional component. For example, suppose you want to install Games as an optional component. To see if Games is installed, look for the following subkey value under the OptionalComponents key:

   "Games"="Games"

Then open the "Games" key under the OptionalComponents key, to find the following:

   HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SETUP\ 
   OptionalComponents\Games
      "INF"="applets.inf"
      "Section"="games"
      "Installed"="0"

This shows that the Games optional component is not installed on this Windows 95 computer because the "Installed" flag is set to 0.

Coding a CreateProcess Function Call

To install an optional component such as Games, use the "INF" and "Section" values in the above key in a CreateProcess call that runs SetupX.dll through RUNDLL. This does exactly what Add/Remove Programs does when it installs a component. The syntax of the lpCommandLine parameter in the CreateProcess call is as follows:

   RunDll setupx.dll,InstallHinfSection <section> <reboot-mode> <inf-name>

The values of the <section> and <inf-name> parameters are those found in the registry key described above. For example, the following CreateProcess call installs the Games optional component (if Windows 95 setup determines that you must restart the computer, it asks the user if he or she wants the computer to restart immediately after the installation is complete. NOTE: The meaning of the <reboot-mode> parameter values is described in the "Using the Reboot Mode Parameter" section of this article):

   RunDll setupx.dll,InstallHinfSection games 4 applets.inf

NOTE: It is recommended that you check the available disk space before installing the component. When checking for available disk space, consider that there must be five to ten Megabytes of disk space for system swap files, and so forth. Also, RUNDLL will process all keys under RunOnce.

Your installation application must not execute any code after the CreateProcess call is made because once SetupX.dll has control, it might cause a reboot. If your installation process requires other code to run after your code makes the CreateProcess call, use the RunOnce list in your .inf file.

NOTE: Do not use the RunOnce list to run the Optional Component that you are installing.

Using the Reboot Mode Parameter

There are five reboot modes:

   define HOW_NEVER_REBOOT         0
   define HOW_ALWAYS_SILENT_REBOOT 1
   define HOW_ALWAYS_PROMPT_REBOOT 2
   define HOW_SILENT_REBOOT        3
   define HOW_PROMPT_REBOOT        4

If <inf-name> specifies your .inf file instead of a Windows 95 .inf file, add 128 to the values shown above. In the previous example that installs the Games optional component, <reboot-mode> is set to 4. This is because Applets.inf is a Windows 95 .inf file. If you were installing an optional component that has its own .inf file, you would set <reboot-mode> to 132. If you add 128 to the <reboot-mode> parameter, all the files you are installing must be in the same directory location as your .inf file on the installation disk.

NOTE: The only recommended values for <reboot-mode> are 4, if the .inf file is a Windows 95 .inf file, or 132 if the .inf file is provided by you. Using any of the other values shown above may cause the computer to be rebooted unnecessarily or cause the computer not to be rebooted when it should be.

The following list describes each reboot mode:

NeverReboot:

Set <reboot-mode> to 0 or 128. Whatever happens, the computer will not be rebooted. It is up to the client to determine if the computer should be rebooted. For setup, this means there is a file C:\Windows\WinInit.ini that is not zero bytes in size.

AlwaysSilentReboot:

Set <reboot-mode> to 1 or 129. The user will not be prompted with a "Reboot the machine, Yes/No" dialog box and the computer will always reboot.

AlwaysPromptReboot:

Set <reboot-mode> to 2 or 130. The user will always be asked to respond to a "Reboot the machine, Yes/No" dialog box. Setup does not attempt to determine if a reboot is necessary.

SilentReboot:

Set <reboot-mode> to 3 or 131. If setup determines that the computer needs to reboot, there is no user interaction.

PromptReboot:

Set <reboot-mode> to 4 or 132. If setup determines that the computer needs to reboot, it prompts the user with a "Reboot the machine, Yes/No" dialog box.

Using the .inf File Install Section Extensions

If you have dependencies on other .inf files, extensions have been added to the .inf file install section format. The following types of items can be added to the install section:

   Include=<list of inf-files>
   Needs=<list of sections>

If there is more than one entry in the Include or Needs items, separate the entries with a comma as shown in the following example:

   Include=mos.inf, msmail.inf
   Needs=MSMAIL, MAPI, MicrosoftNetwork

The Include item enables you to specify .inf files that setup must also load into memory when it loads your .inf file because these .inf files contain sections that must be run in addition to the install sections in your .inf file. The Needs item specifies the names of the sections you intend to run in the included .inf file(s).

For example, you could add the following lines to an install section in your .inf file:

   [InstallMyToys]
       .
       .
       .
   Include=mos.inf, msmail.inf
   Needs=MSMAIL, MAPI, MicrosoftNetwork

Running an .inf File by Right-clicking It

Setup recognizes a particular install section name, DefaultInstall, in .inf files that install optional components. If you use a [DefaultInstall] section in your .inf file, the user can right-click on a file icon for the .inf file in the Windows 95 user interface to run the [DefaultInstall] section. (After the user right-clicks on the .inf file icon, a popup menu appears. The user must select the Install option in this menu to actually run the [DefaultInstall] section.)

Using an install section named [DefaultInstall] in your .inf file provides a convenient method for installing your optional component, which is particularly useful during development of your application. If you are going to write an installation application, you have a method for installing your optional component before you develop the installation application code.

An example DefaultInstall section is provided below to show that its entries are typical of most .inf file install sections:

   [DefaultInstall]
   CopyFiles=QCD.copy.prog, QCD.copy.hlp, QCD.copy.win, QCD.copy.sys,
      QCD.copy.inf
   UpdateInis=QCD.Links
   AddReg=QCD.reg, QCD.run
   Uninstall=FlexiCD_remove

Additional query words:
Keywords          : kbDDK kbWinOS95 
Issue type        : kbhowto

Last Reviewed: October 22, 1998