I'm having trouble opening a WinUSB handle from an application. I have
successfully installed the WinUSB driver and am working on opening a handle
to it. Here are the setps I have been trying to follow (I have code if you
would like to see it):

1) I set up my InterfaceGuid (getting same one from my INF file)
2) Get handle to ClassInfo from InterfaceGuid
3) Call SetupDiEnumDeviceInterfaces in a while loop to get number of USB
device interfaces. For my purposes, this will be the number of actual
devices. My code works fine up to this step...
4) In for loop, call the following:
a. SetupDiEnumDeviceInterfaces (once again)
b. SetupDiGetDeviceInterfaceDetail (to get size of device interface path)
c. SetupDiGetDeviceInterfaceDetail (again, to actually get device
interface path)
d. Save all this in a struct of some kind, say, "DeviceList".
5) Go through DeviceList, get interface handle to the device of my choosing
with call to CreateFile.
6) FINALLY, get handle to WinUSB from interface handle


I'm having trouble with step 4. Help. Any pointers? Any code that can be
shared with me? Is there a shorter/quicker method?

Thanks...

RE: Opening a WinUSB handle by bjhindman

bjhindman
Fri Mar 16 20:15:00 CDT 2007

Yes, I finally found a nice code example in the current WDK from Microsoft
(Ver 6000). Specifically, the source can be found to the USBVIEW example (in
the enum.c code module). With that I was able to retrieve the "device
interface path"...

Thanks,

"bjhindman" wrote:

> I'm having trouble opening a WinUSB handle from an application. I have
> successfully installed the WinUSB driver and am working on opening a handle
> to it. Here are the setps I have been trying to follow (I have code if you
> would like to see it):
>
> 1) I set up my InterfaceGuid (getting same one from my INF file)
> 2) Get handle to ClassInfo from InterfaceGuid
> 3) Call SetupDiEnumDeviceInterfaces in a while loop to get number of USB
> device interfaces. For my purposes, this will be the number of actual
> devices. My code works fine up to this step...
> 4) In for loop, call the following:
> a. SetupDiEnumDeviceInterfaces (once again)
> b. SetupDiGetDeviceInterfaceDetail (to get size of device interface path)
> c. SetupDiGetDeviceInterfaceDetail (again, to actually get device
> interface path)
> d. Save all this in a struct of some kind, say, "DeviceList".
> 5) Go through DeviceList, get interface handle to the device of my choosing
> with call to CreateFile.
> 6) FINALLY, get handle to WinUSB from interface handle
>
>
> I'm having trouble with step 4. Help. Any pointers? Any code that can be
> shared with me? Is there a shorter/quicker method?
>
> Thanks...
>