delphi 使用INF文件

来源:互联网 发布:js卫生间防水质量通病 编辑:程序博客网 时间:2024/05/29 21:18

转自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) ;

 

原创粉丝点击