Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Installing INF file programtically?

Posted on 2002-06-03
6
Medium Priority
?
367 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 2

Accepted Solution

by:
freshman3k earned 400 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

705 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