SetupOpenInfFile
The SetupOpenInfFile function opens an INF file and returns a handle to it.
HINF SetupOpenInfFile(
PCTSTR FileName, // name of the INF to open
PCTSTR InfClass, // optional, the class of the INF file
DWORD InfStyle, // specifies the style of the INF file
PUINT ErrorLine // optional, receives error information
);
Parameters
-
FileName
-
Points to a null-terminated string containing the name (and optional path) of the INF file to be opened. If the filename does not contain path separator characters, it is searched for, first in the %windir%\inf directory, and then in the %windir%\system32 directory. If the filename contains path separator characters, it is assumed to be a full path specification and no further processing is performed on it.
-
InfClass
-
An optional parameter that points to a null-terminated string containing the class of INF file desired. For legacy INF files, this string must match the type specified in the OptionType value of the Identification section in the INF file (for example, OptionType=NetAdapter). For Windows 95- or Windows NT 4.0-style INF files, this string must match the Class value of the Version section (for example, Class=Net). If there is no entry in the Class value, but there is an entry for ClassGUID in the Version section, the corresponding class name for that GUID is retrieved and used for the comparison.
-
InfStyle
-
Specifies the style of INF file to open. May be a combination of the following flags:
-
INF_STYLE_OLDNT
-
Windows NT 3.x script-based INF files.
-
INF_STYLE_WIN4
-
Windows 95- or Windows NT 4.0-style INF files.
-
ErrorLine
-
An optional parameter that points to a caller-supplied variable to which this function returns the (1-based) line number where an error occurred during loading of the INF file. This value is generally reliable only if GetLastError does not return ERROR_NOT_ENOUGH_MEMORY. If an out-of-memory condition does occur, ErrorLine may be 0.
Return Values
The function returns a handle to the opened INF file if it is successful. Otherwise, the return value is INVALID_HANDLE_VALUE. Extended error information can be retrieved by a call to GetLastError.
Remarks
If the load fails because the INF file type does not match InfClass, the function returns INVALID_HANDLE_VALUE and a call to GetLastError returns ERROR_CLASS_MISMATCH.
If multiple INF file styles are specified, the style of the INF file opened can be determined by calling the SetupGetInfInformation function.
Since there may be more than one class GUID with the same class name, callers interested in INF files of a particular class (that is, a particular class GUID) should retrieve the ClassGUID value from the INF file by calling SetupQueryInfVersionInformation.
QuickInfo
Windows NT: Use version 4.0 and later.
Windows: Use Windows 95 and later.
Windows CE: Unsupported.
Header: Declared in setupapi.h.
Import Library: Link with setupapi.lib.
See Also
Overview, Functions, SetupOpenAppendInfFile, SetupCloseInfFile, SetupGetInfInformation