Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am wanting a HID USB Interface to connect to a USB device I am developing. I understand that I need a device path to pass to CreateFile to get a handle. Once I have a handle I can read and write to the device.

As a stating point I have developed an app that lists USB HID devices by description and device path. It uses setupapi.dll. This works brilliantly on the machine I developed it on: VS2005 and 64bit Windows 7.

However it does not work on a 32 bit XP machine with VS2005 installed on it or a 64 bit Window 7 machine without VS2005 installed. DependencyWalker tells me that the XP setupapi.dll does not have the function SetupDiGetDevicePropertyW.

Three questions:
1. Is there a straightforward way of getting the app to work on all platforms?
2. Why can't I use parameters from the registry since everything I need seems to be in there?
3. Is the registry parameter SymbolicName the same as the device path needed by CreateFile?
Posted

1 solution

1. See the requirements section at http://msdn.microsoft.com/en-us/library/windows/hardware/ff551963(v=vs.85).aspx[^]. This function is available on Windows Vista and above. You will also need to have the DLL on the system, I don't think it comes as standard, which is why VS is also required.

2. You probably can, but the Setup functions sometimes need to do more than just reading the registry, so you are generally advised not to rely on it.

3. Sorry, don't know.
 
Share this answer
 
v2
Comments
Doug Richards 18-Jan-14 23:21pm    
Thank you. It seems like I need SetupDiGetDeviceRegistryProperty for XP. Which is seems is just reading the registry.
Regarding the VS requirement, I believe there is a VS runtime that can be installed with apps. However, I don't understand why it would be required here. setupapi.h and setupapi.lib are compiled with the app and some version of setupapi.dll is installed on every machine I have seen.
Richard MacCutchan 19-Jan-14 4:15am    
and some version of setupapi.dll is installed on every machine
True, but if your build targets a later version than the one in XP you will often get problems similar to the above.
Doug Richards 20-Jan-14 4:03am    
All working now. SetupDiGetDeviceRegistryProperty is almost a direct replacement for SetupDiGetDevicePropery and works on 32 bit Windows XP.
A release version of the same code also works on 64 bit Windows 7 without VS installed.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900