winapisetupapi

SetupAPI - SetupDiGetDeviceRegistryProperty substitute?


I need to use some SetupAPI functions in firefox extension. I need to retrieve device's friendly name. I figured it can be done by SetupDiGetClassDevs, SetupDiEnumDeviceInfo, SetupDiGetDeviceRegistryProperty and SetupDiDestroyDeviceInfoList.

BUT! I imported the setupapi.dll and declared three of the functions - no problem. Then I found out that SetupDiGetDeviceRegistryProperty simply isn't in the DLL at all and can only be statically linked with setupapi.lib. Is there any way I could substitute this function?

I cannot use WMI.


Solution

  • This function is indeed in SetupAPI.DLL, as I've confirmed using Dependency Walker. It's just that, it takes a character-pointer (string), it has to have two variants - one for ANSI (A), one for Unicode (W).

    It is with any Windows API function - if function takes one or more of character-string as arguments, it would have two variants.

    I see you are probably using GetProcAddress to locate it. Hence, you need to pass real name (not macro) to it. Following gets wide-variant of this function.

    GetProcAddress(handleOfDLL, "SetupDiGetDeviceRegistryPropertyW"); // Wide