Automatic driver search install using an inf file - FTDI

I have a device that uses FTDI's FT245B chip.  They provide the drivers for this chip.  I have a vb.net (vs2005) windows application that the user uses to access my device over USB.  The problem I am having is the user has to install the drivers first and the way it is now they have to find the drivers by browsing to them to where they installed the program at before windows Find New Hardware wizard can install the drivers.  This is a problem for most users.  

My question is how do I install this inf file so windows knows where the driver is located so the user can just click to search automatically?
Do I need to make a change to the INF file?
Is there some code in vb.net I can do this with?

The drivers can be found here:
http://www.ftdichip.com/Drivers/D2XX.htm
version 2.06.02

Thanks for the help!
LVL 3
deer22Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Meir RivkinFull stack Software EngineerCommented:
0
Meir RivkinFull stack Software EngineerCommented:
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
deer22Author Commented:
Thanks sedqwick I got it working now and works fine with the warnings of course since the drivers are not signed.  I tested it with XP and Windows 7.  Windows 7 didn't even make me use the FNHW, it just installed them automatically when I connected the device.  I still had to use the FNHW on XP, but didn't have to manually locate the drivers like I use to.  Great to know...Heck FTDI themselves didn't even know how to do it...lol...Anyways, I am posting some code below that should help save developers a lot of time...this code is in VB.net and was written using visual studio 2005...

Note: Drivers are NOT added to Add?Remove Programs in Control Panel and I haven't tried uninstalling them...just manually so far...we'll leave that for another day...

Imports System.Runtime.InteropServices

Imports System.Runtime.InteropServices.Marshal

Const DRIVER_PACKAGE_REPAIR As Int32 = &H1

Const DRIVER_PACKAGE_SILENT As Int32 = &H2

Const DRIVER_PACKAGE_FORCE As Int32 = &H4

Const DRIVER_PACKAGE_ONLY_IF_DEVICE_PRESENT As Int32 = &H8

Const DRIVER_PACKAGE_LEGACY_MODE As Int32 = &H10

Const DRIVER_PACKAGE_DELETE_FILES As Int32 = &H20

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Auto)> _

Public Structure INSTALLERINFO

Public pApplicationId As String

Public pDisplayName As String

Public pProductName As String

Public pMfgName As String

End Structure

'This will pre install the inf file (UNSIGNED) into the Driver store

'Location Example - C:\WINDOWS\system32\DRVSTORE

'Has been tested on XP and Windows 7, should work on any version after Win2000

'

'##############################################################################

'Note: if the device is connected before running code below the drivers will

'be installed without using Found New Hardware Wizard. If the device is not

'connected then FNHW is used on XP. On Windows 7 the drivers are installed

'without the FNHW as soon as the device is connected.

'

'location of the inf file

Dim infFile As String = SourceINFFILE

'DRIVER_PACKAGE_LEGACY_MODE - obsolete on Vista and later, however,

'it still works with unsigned drivers on these systems

'DRIVER_PACKAGE_REPAIR - forces installation, otherwise, if already pre-installed

'causes an error.

Dim Flags As Int32 = DRIVER_PACKAGE_LEGACY_MODE Or DRIVER_PACKAGE_REPAIR

'reboot after install

Dim fNeedReboot As Boolean = False

'Structure relates driver package with an application

Dim installerInfo As INSTALLERINFO = New INSTALLERINFO()

installerInfo.pApplicationId = vbEmpty 'GUID

installerInfo.pDisplayName = vbEmpty

installerInfo.pProductName = vbEmpty

installerInfo.pMfgName = vbEmpty

Dim ptrInstallerInfo As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(installerInfo))

Marshal.StructureToPtr(installerInfo, ptrInstallerInfo, False)

Dim InstallResult As Int32 = DriverPackageInstall(infFile, Flags, ptrInstallerInfo, fNeedReboot)

Marshal.FreeHGlobal(ptrInstallerInfo)

0
deer22Author Commented:
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Hardware

From novice to tech pro — start learning today.