Click to Rate and Give Feedback
MSDN
MSDN Library
Setup API
Reference
Functions
 InstallHinfSection Function
InstallHinfSection Function

InstallHinfSection is an entry-point function exported by Setupapi.dll that you can use to execute a section of an .inf file. InstallHinfSection can be invoked by calling the Rundll32.exe utility as described in the Remarks section.

The prototype for the InstallHinfSection function follows the form of all entry-point functions used with Rundll32.exe.

If a file is copied or modified, the caller of this function is required have privileges to write into the target directory. If there are any services being installed, the caller of this function is required have access to the Service Control Manager.

Syntax

VOID CALLBACK InstallHinfSection(
  __in  HWND hwnd,
  __in  HINSTANCE ModuleHandle,
  __in  PCTSTR CmdLineBuffer,
  __in  INT nCmdShow
);

Parameters

hwnd

The parent window handle. Typically hwnd is Null.

ModuleHandle

Reserved and should be Null.

CmdLineBuffer

Pointer to buffer containing the command line. You should use a null-terminated string.

nCmdShow

Reserved and should be zero.

Return Value

This function does not return a value.

Remarks

Note that three exports exist: InstallHinfSection (for RunDll32), InstallHinfSectionA, and InstallHinfSectionW.

To run an Install section of a specified .inf file, you can invoke InstallHinfSection with the Rundll32.exe by using the following syntax.

RUNDLL32.EXE SETUPAPI.DLL,InstallHinfSection <section><mode><path>

This passes "<section> <mode> <path>" to CmdLineBuffer.

Alternatively, your program may call InstallHinfSection, InstallHinfSectionA, or InstallHinfSectionW directly, setting the CmdLineBuffer parameter to the following.

 "<section> <mode> <path>"

Where path is the full path to the .inf file, mode is the reboot mode parameter, and section is any Install section in the .inf file. The comma separator between SETUPAPI.DLL and InstallHinfSection on the command line is required. Note that there cannot be any white space on the command line between the comma and SETUPAPI.DLL or InstallHinfSection.

It is recommended that you specify the full path to the .inf file as path.

You may specify any Install section in the .inf file as section. No spaces are allowed.

You should use a combination of the following values for mode. You must include 128 to set the default path of the installation to the location of the INF, otherwise a system-provided INF is assumed. Add values to specify rebooting. Note that only the values 128 or 132 are recommended, other values may cause the computer to reboot unnecessarily or not reboot when it required.

Value Description
0 System provided INF.
128 Set the default path of the installation to the location of the INF. This is the typical setting.
+0 Never reboot the computer.
+1 Reboot the computer in all cases.
+2 Always ask the users if they want to reboot.
+3 Reboot the computer if necessary without asking user for permission.
+4 If a reboot of the computer is necessary, ask the user for permission before rebooting.


For example, the following command line runs the DefaultInstall section of the Shell.inf file. If Setup determines a reboot is required, the user is will be prompted with a "Reboot the computer, Yes/No" dialog box.

RUNDLL32.EXE SETUPAPI.DLL,InstallHinfSection DefaultInstall 132 C:\WINDOWS\INF\SHELL.INF

Requirements

Client Requires Windows Vista, Windows XP, or Windows 2000 Professional.
Server Requires Windows Server 2008, Windows Server 2003, or Windows 2000 Server.
Header

Declared in Setupapi.h.

Library

Use Setupapi.lib.

DLL

Requires Setupapi.dll.

Unicode

Implemented as InstallHinfSectionW (Unicode) and InstallHinfSectionA (ANSI).


Send comments about this topic to Microsoft

Build date: 2/7/2008

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Using InstallHinfSection in GPO-deployed installation packages      GeneRi   |   Edit   |  
Using a mode of 132 can break an installation package that is being deployed to Vista machines via Group Policy Objects. You may want to use a mode of 128 instead. GPO deployment seems to be a special case of the problem and solution that was described in http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=627328&SiteID=1.
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker