CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
不看会后悔的Windows XP之经验谈 简单快捷DIY实用家庭影院
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  VC/MFC >  基础类

急:这个API花了我一天时间,还是???

楼主qiuanhong(练从难处练,用从易处用)2002-02-05 10:01:25 在 VC/MFC / 基础类 提问

这个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

相关问题

  • 急~~~~C#里怎么调用Windows API控制时间?2小时后结贴~
  • 求与系统时间相关的API函数?如何编程修改电脑时间?急用!先谢了!
  • 求与系统时间相关的API函数?即如何编程修改电脑时间?急用!先谢了!
  • 寻求api 急!!!!!!!!!!!!!!!!!!
  • 急 USB API
  • 急救!!!!!!!!! 请问shutdown要花多少时间?
  • 请教取CMOS时间的API函数,,???
  • Shell ApI 问题,急。
  • 什么是API?急!
  • 什么是API?急!

关键词

  • errorline
  • 参数
  • setupopeninffile
  • 帮帮
  • pctstr
  • infclass
  • puint
  • inf
  • optional
  • uint

得分解答快速导航

  • 帖主:qiuanhong
  • TeddyWing

相关链接

  • Visual C++类图书
  • Visual C++类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo