Mega Code Archive

 
Categories / Delphi / Examples
 

Silently installing an inf file from your delphi application

Question: My self-written install program needs to install a 3rd party tool which comes with an .INF file. How do I call it up to install invisible ('silent install')? Answer: The INF file format has been around for many years at least since Windows 3 and it has many options including modifications in the registry, driver installation or date and version control. There are even free tools available to generate INF files. Executing them from a Delphi application is no problem if you use the function shown below. Simply pass the path to the .INF file and handle of your form (use 0 if you have a console application). uses ShellAPI; function InstallINF(const PathName: string; hParent: HWND) : boolean; var instance: HINST; begin { InstallINF } instance := ShellExecute( hParent, PChar('open'), PChar('rundll32.exe'), PChar('setupapi,InstallHinfSection DefaultInstall 132 ' + PathName), nil, SW_HIDE); Result := instance>32 end; { InstallINF }