1

我需要在 firefox 扩展中使用一些 SetupAPI 函数。我需要检索设备的友好名称。我认为它可以通过SetupDiGetClassDevs,SetupDiEnumDeviceInfoSetupDiGetDeviceRegistryProperty来完成SetupDiDestroyDeviceInfoList

但!我导入setupapi.dll并声明了其中的三个函数——没问题。然后我发现SetupDiGetDeviceRegistryProperty根本不在 DLL 中,只能与setupapi.lib. 有什么办法可以代替这个功能吗?

我无法使用 WMI。

4

2 回答 2

1

您是对的,没有具有该确切名称的导出。该名称实际上是在 SetupApi 标头中定义的,就像 Windows API 中具有 Unicode 和 ANSI 变体的大多数函数一样。

从 SetupApi.h:

#ifdef UNICODE
#define SetupDiGetDeviceRegistryProperty SetupDiGetDeviceRegistryPropertyW
#else
#define SetupDiGetDeviceRegistryProperty SetupDiGetDeviceRegistryPropertyA
#endif

该函数在导出表中为 SetupDiGetDeviceRegistryPropertyW(序号:373)或 SetupDiGetDeviceRegistryPropertyA(序号:372)

我发现那些使用dumpbin /exports setupapi.dll.

于 2016-05-24T15:15:45.357 回答
1

这个函数确实在 SetupAPI.DLL 中,正如我使用 Dependency Walker 确认的那样。就是这样,它需要一个字符指针(字符串),它必须有两种变体——一种用于 ANSI(A),一种用于 Unicode(W)。

  • SetupDiGetDeviceRegistryPropertyA
  • SetupDiGetDeviceRegistryPropertyW

它适用于任何 Windows API 函数 - 如果函数将一个或多个字符串作为参数,它将有两个变体。

我看到您可能正在使用GetProcAddress它来定位它。因此,您需要将真实姓名(而不是宏)传递给它。以下获得此功能的广泛变化。

GetProcAddress(handleOfDLL, "SetupDiGetDeviceRegistryPropertyW"); // Wide
于 2016-05-25T07:36:29.283 回答