Solved

Installing INF file programtically?

Posted on 2002-06-03
6
339 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

757 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now