Solved

Installing INF file programtically?

Posted on 2002-06-03
6
344 Views
Last Modified: 2010-04-04
Here's my situation. I have a third party driver which I need to install prior to my application. I am trying to make this as user friendly as possible, meaning that I would like to eliminate any user intervention for the driver install. How to I programatically simulate a right click/Install of the INF file? Points for working example.

Thanks!!
0
Comment
Question by:DrDelphi
6 Comments
 
LVL 2

Accepted Solution

by:
freshman3k earned 100 total points
ID: 7051885
Hello!

Here is Working Code:

procedure installInfFile(Inffile: String );
var
Path: string;
VI: TOSVersionInfo;
O: Integer;
begin

 VI.dwOSVersionInfoSize := SizeOf(VI);
 GetVersionEx(VI);
   
 if VI.dwPlatformID = VER_PLATFORM_WIN32_WINDOWS then begin
    Path:='setupx.dll,InstallHinfSection DefaultInstall 130'+InfFile;
    end;
 if VI.dwPlatformID = VER_PLATFORM_WIN32_NT then begin  
    Path:='setupapi.dll,InstallHinfSection DefaultInstall 130'+InfFile;
    end;

 ShellExecute(Handle,'open','rundll32.exe',PChar(Path),nil,SW_SHOWNORMAL);

end;

Example:
installInfFile('c:\myfolder\myinf.inf');

Good Luck! :-)
0
 
LVL 11

Expert Comment

by:robert_marquardt
ID: 7052012
I have converted the SetupApi (http://delphi-jedi.org/APILIBRARY), but i have never used all functions therein.
0
 
LVL 6

Author Comment

by:DrDelphi
ID: 7052030
Testing it out....


0
 
LVL 2

Expert Comment

by:freshman3k
ID: 7052111
Hello Again!

Sorry for my mistakes in the code its just that I was in a hurry!

So here is the corrected code:

procedure installInfFile(InfFile: String );
var
InfFile: String;
VI: TOSVersionInfo;
begin

VI.dwOSVersionInfoSize := SizeOf(VI);
GetVersionEx(VI);
 
if VI.dwPlatformID = VER_PLATFORM_WIN32_WINDOWS then begin
   Path:='setupx.dll,InstallHinfSection DefaultInstall 130'+InfFile;
   end;
if VI.dwPlatformID = VER_PLATFORM_WIN32_NT then begin  
   Path:='setupapi.dll,InstallHinfSection DefaultInstall 130'+InfFile;
   end;

ShellExecute(Handle,'open','rundll32.exe',PChar(Path),nil,SW_SHOWNORMAL);

end;

Example:
installInfFile('c:\myfolder\myinf.inf');
0
 
LVL 1

Expert Comment

by:pnh73
ID: 9010429
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Accept answer from freshman3k

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Paul (pnh73)
EE Cleanup Volunteer
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Convert Jpg /PNG To GIF 5 136
Comparing dates in Delphi. Greater than/ Less than 3 154
QRReport  TQrmemo vertical stretching 1 46
Multiple image collision 13 75
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question