delphi 使用INF文件

转自http://blog.csdn.net/g_min/article/details/3874764

  1. If you need to install an "inf" file using Delphi, you could use the next code:   
  2. ~~~~~~~~~~~~~~~~~~~~~~~~~  
  3. { 
  4. Usage: 
  5.    InstallINF('C:/XYZ.inf', 0) ; 
  6. }  
  7. uses  
  8.    ShellAPI;  
  9.   
  10. function InstallINF(const PathName: string; hParent: HWND): Boolean;  
  11. var  
  12.    instance: HINST;  
  13. begin  
  14.    instance := ShellExecute(hParent,  
  15.      PChar('open'),  
  16.      PChar('rundll32.exe'),  
  17.      PChar('setupapi,InstallHinfSection  
  18.            DefaultInstall 132 ' + PathName),  
  19.      nil,  
  20.      SW_HIDE) ;  
  21.   
  22.    Result := instance > 32;  
  23. end;  
  24.   
  25. ~~~~~~~~~~~~~~~~~~~~~~~~~  
1, 用copyFile复制文件,
CopyFile('C:\\Autoexec.bat', 'A:\\Backup\\Autoexec.bat', False);

2. 可以用shellExecute加载已有的exe文件(应该也可以调用inf文件),比如运行记事本:
uses ShellApi;  // 加在开头units 中
ShellExecute(Handle, 'open', 'c:\Windows\notepad.exe', nil, nil, SW_SHOWNORMAL) ;
ShellExecute(Handle, 'open', 'C:\\xxx.inf', nil, nil, SW_SHOWNORMAL) ;

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值