急:这个API花了我一天时间,还是???
这个API花了我一天时间,还是不行:
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
);
假如我有一个文件:serwpl.inf 存放在光盘中,其参数应该怎样设置?
特别是第四个参数
问题点数:5、回复次数:7Top
1 楼qiuanhong(练从难处练,用从易处用)回复于 2002-02-05 10:20:21 得分 0
快帮帮我.....
快帮帮我.....
快帮帮我.....
快帮帮我.....
快帮帮我.....Top
2 楼shawn_liu()回复于 2002-02-05 10:28:53 得分 0
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.
Requirements
Windows NT/2000: Requires Windows NT 4.0 or later.
Windows 95/98: Requires Windows 95 or later. Available as a redistributable for Windows 95.
Header: Declared in Setupapi.h.
Library: Use Setupapi.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000.Top
3 楼qiuanhong(练从难处练,用从易处用)回复于 2002-02-05 10:43:39 得分 0
在.cpp中加入了下面的语句:
#include "setupapi.h"
HINF hInf;
LPCTSTR filename="SERWPL.INF";
LPCTSTR InfClass="USB";
UINT lErrorLine;
hInf=::SetupOpenInfFile(filename,InfClass,INF_STYLE_WIN4,&lErrorLine);
编译都没有通过,出错如下:
MessageDlg.obj : error LNK2001: unresolved external symbol _SetupOpenInfFileA@16
Debug/Message.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Message.exe - 2 error(s), 0 warning(s)
怎么解决?MSDN我这也有.Top
4 楼TeddyWing(胡涂窗口)回复于 2002-02-05 10:51:31 得分 5
Pay attention:
Library: Use Setupapi.lib.
Add Setupapi.lib in your project.
Top
5 楼qiuanhong(练从难处练,用从易处用)回复于 2002-02-05 10:56:11 得分 0
Thank you!
your E_mail?
Top
6 楼dct1999(宇宙天空)回复于 2002-02-05 11:09:33 得分 0
说的对,都没有链接库,当然出错拉,下次记住了.Top
7 楼Earthdog(没有女朋友,郁闷!)回复于 2002-02-05 11:24:40 得分 0
MSDN中对于这个参数的解释如下:
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.
中文意思是:
ErrorLine是一个可选参数,有调用者自己提供支持,当加载INF文件出错是,函数返回错误所在的行数(从1开始),只有当GetLastError的返回值不是ERROR_NOT_ENOUGH_MEMORY的时候,这个参数才有用。如果内存不够,则ErrorLine的值将是0。
其实这个参数不是一个传入参数,而是一个传出参数,PUINT是指向UINT类型的指针,你只需要定义一个UINT类型的参数,而后传入它的地址即可。如下所示:
UINT nErrorLine;
SetupOpenInfFile(..., ..., ..., &nErrorLine);Top




