Solved

Installing INF file programtically?

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

863 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

27 Experts available now in Live!

Get 1:1 Help Now