我需要在火狐扩展中使用一些SetupAPI函数。我要找回设备友好的名字。我想这可以由SetupDiGetClassDevs,SetupDiEnumDeviceInfo,SetupDiGetDeviceRegistryProperty和SetupDiDestroyDeviceInfoList来完成。
但!我导入了setupapi.dll并声明了其中的三个函数--没问题。然后我发现SetupDiGetDeviceRegistryProperty根本不在DLL中,只能与setupapi.lib静态链接。有什么办法可以替代这个功能吗?
我不能使用WMI。
发布于 2016-05-25 07:36:29
这个函数确实在SetupAPI.DLL中,正如我使用依赖沃克所确认的那样。只是,它需要一个字符指针(string),它必须有两个变体-一个用于ANSI (A),一个用于Unicode (W)。
SetupDiGetDeviceRegistryPropertyASetupDiGetDeviceRegistryPropertyW它与任何Windows函数--如果函数以一个或多个字符串作为参数--将有两个变量。
我看你可能在用GetProcAddress来定位它。因此,您需要将实名(而不是宏)传递给它。下面是这个函数的大变体。
GetProcAddress(handleOfDLL, "SetupDiGetDeviceRegistryPropertyW"); // Wide发布于 2016-05-24 15:15:45
你说得对,没有那个名字的出口。这个名称实际上是在SetupApi头中定义的,就像Windows中大多数具有Unicode & ANSI变体的函数一样。
来自SetupApi.h:
#ifdef UNICODE
#define SetupDiGetDeviceRegistryProperty SetupDiGetDeviceRegistryPropertyW
#else
#define SetupDiGetDeviceRegistryProperty SetupDiGetDeviceRegistryPropertyA
#endif函数在导出表中作为SetupDiGetDeviceRegistryPropertyW (序数: 373)或SetupDiGetDeviceRegistryPropertyA (序号: 372)。
我发现那些使用dumpbin /exports setupapi.dll的。
https://stackoverflow.com/questions/37416519
复制相似问题