deer22
asked on
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!
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!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.InteropServ ices
Imports System.Runtime.InteropServ ices.Marsh al
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_DEV ICE_PRESEN T As Int32 = &H8
Const DRIVER_PACKAGE_LEGACY_MODE As Int32 = &H10
Const DRIVER_PACKAGE_DELETE_FILE S As Int32 = &H20
<StructLayout(LayoutKind.S equential, 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\DRVSTO RE
'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_MOD E - 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.pApplication Id = vbEmpty 'GUID
installerInfo.pDisplayName = vbEmpty
installerInfo.pProductName = vbEmpty
installerInfo.pMfgName = vbEmpty
Dim ptrInstallerInfo As IntPtr = Marshal.AllocHGlobal(Marsh al.SizeOf( installerI nfo))
Marshal.StructureToPtr(ins tallerInfo , ptrInstallerInfo, False)
Dim InstallResult As Int32 = DriverPackageInstall(infFi le, Flags, ptrInstallerInfo, fNeedReboot)
Marshal.FreeHGlobal(ptrIns tallerInfo )
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.InteropServ
Imports System.Runtime.InteropServ
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_DEV
Const DRIVER_PACKAGE_LEGACY_MODE
Const DRIVER_PACKAGE_DELETE_FILE
<StructLayout(LayoutKind.S
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\DRVSTO
'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_MOD
'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
'reboot after install
Dim fNeedReboot As Boolean = False
'Structure relates driver package with an application
Dim installerInfo As INSTALLERINFO = New INSTALLERINFO()
installerInfo.pApplication
installerInfo.pDisplayName
installerInfo.pProductName
installerInfo.pMfgName = vbEmpty
Dim ptrInstallerInfo As IntPtr = Marshal.AllocHGlobal(Marsh
Marshal.StructureToPtr(ins
Dim InstallResult As Int32 = DriverPackageInstall(infFi
Marshal.FreeHGlobal(ptrIns
ASKER
Here is another link that may help out...
http://www.pinvoke.net/default.aspx/difxapi/DriverPackageInstall.html
http://www.pinvoke.net/default.aspx/difxapi/DriverPackageInstall.html
http://msdn.microsoft.com/en-us/library/ff544775.aspx
check those posts as well:
http://www.appdeploy.com/messageboards/tm.asp?m=28204&mpage=1&key=difx渭
http://bytes.com/topic/visual-basic-net/answers/777212-how-install-uninstall-inf-driver