转自http://blog.csdn.net/g_min/article/details/3874764
- If you need to install an "inf" file using Delphi, you could use the next code:
- ~~~~~~~~~~~~~~~~~~~~~~~~~
- {
- Usage:
- InstallINF('C:/XYZ.inf', 0) ;
- }
- uses
- ShellAPI;
- function InstallINF(const PathName: string; hParent: HWND): Boolean;
- var
- instance: HINST;
- begin
- instance := ShellExecute(hParent,
- PChar('open'),
- PChar('rundll32.exe'),
- PChar('setupapi,InstallHinfSection
- DefaultInstall 132 ' + PathName),
- nil,
- SW_HIDE) ;
- Result := instance > 32;
- end;
- ~~~~~~~~~~~~~~~~~~~~~~~~~
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) ;