UltimaSerial
Windaq Add-ons
UltimaWaterfall
XChart
FFT1024
Lessons
|
|
Any USB devices need its driver(s) to run under Window
The traditional way to do it was:
- Plug in the USB device
- Windows detects it and ask for a driver, like this
- You feed a CD containing the driver(s) and follow the instruction to
finish the installation. If your driver is not signed by Microsoft,
you will run into a warning like this:
- When you move the device to a different USB port, you may have to go
through step 2) and 3) again
With the latest Windows, you can pre-install the USB driver(s) so that
Windows will not ask you for drivers when you plug in the device
To do so, you can write a small program to call SetupCopyOEMInf to let
Windows know that you have supply the drivers for the USB device ahead of
time. For more info regarding SetupCopyOEMInf, you can read it on http://msdn.microsoft.com/en-us/library/aa376990%28VS.85%29.aspx.
If you have VB6, here is the codes for the little utility:
Private Declare Function SetupCopyOEMInf Lib "setupapi.dll" Alias "SetupCopyOEMInfA" _
(ByVal SourceInfFileName As String, ByVal OEMSourceMediaLocation As String, _
ByVal OEMSourceMediaType As Long, ByVal CopyStyle As Long, ByVal DestinationInfFileName As String, _
ByVal DestinationInfFileNameSize As Long, ByRef RequiredSize As Long, _
ByVal DestinationInfFileNameComponent As String) _
As Long
Private Sub Form_Load()
On Error Resume Next
Dim param() As String
Dim ret2 As String * 255
Dim ret3 As String * 255
Dim ret As Long
If Command = "" Then End
param = Split(Command, "@@")
ret = SetupCopyOEMInf(param(0), param(1), 1, &H4, ret2, 255, 255, ret3)
If ret = 0 And UBound(param) = 2 Then
MsgBox "Sorry, but we failed in pre-installing USB drivers on this PC"
End If
End
End Sub
If you don't have VB6 around, here is the .exe
form of this utility
To use this utility
- You need to pay to have your USB drivers signed by Microsoft.
Otherwise pre-installing USB drivers will generate more Windows
warnings than the traditional approach
- Once your drivers, including .inf and .sys files are signed. You can
use any installation program to copy them, along with necessary .cat,
.sys and .dlls
to a target directory.
- From the installation script, spawn the utility created above, with
the following parameters <path of inf>@@<path of
directory>, where @@ is the separator, e.g. c:\ultimaserial\usbdrivers\ftdiport.inf@@c:\ultimaserial\usbdrivers
- Repeat 3 for all necessary inf files.
- Once the all drivers are pre-installed, your USB device can pick up
them automatically when it is plugged into your PC.
For Vista users
Unfortunately, due to the missing manifest in VB6 apps, you may see a nagging window complaining the program might not have installed
correctly. To address this problem, you may want to write this little program using Visual C++ 2008
Expression.
- Create a Win32 console application
- Use the following codes
#include "stdafx.h"
#include <windows.h>
#include <setupapi.h>
int main(int
argc, char *argv[])
{
wchar_t ret2[256];
wchar_t ret3[256];
wchar_t wcstring1[200];
wchar_t wcstring2[200];
size_t convertedChars1 = 0;
size_t convertedChars2 = 0;
if (argc==3){
size_t origsize1 = strlen(argv[1]) + 1;
mbstowcs_s(&convertedChars1, wcstring1, origsize1, argv[1],
_TRUNCATE);
size_t origsize2 = strlen(argv[2]) + 1;
mbstowcs_s(&convertedChars2, wcstring2, origsize2, argv[2],
_TRUNCATE);
ret=SetupCopyOEMInf(wcstring1, wcstring2, 1, 4, ret2,255, NULL,NULL);
if (ret==0) printf("Failed to preinstall (%d)",
GetLastError());
}
else printf("Wrong format");
}
#include "stdafx.h"
#include <windows.h>
#include <setupapi.h>
int main(int
argc,
wchar_t argv[])
{
wchar_t ret2[256];
if (argc==3){
if
(SetupCopyOEMInf(argv[1], argv[2], 1, 4, ret2,255, NULL,NULL)==0) printf("Failed to preinstall (%d)",
GetLastError());
}
else printf("Wrong format");
}
- Call this utility with the parameters <path of inf> <path of
directory>, e.g. c:\ultimaserial\usbdrivers\ftdiport.inf c:\ultimaserial\usbdrivers
- Or, you can also try the compiled
version of this utility
Last update: 03/12/13
Copyright: 2000-2005
www.UltimaSerial.com
|