未解析的外部符号_DEVPKEY_Device_BusReportedDeviceDesc [英] unresolved external symbol _DEVPKEY_Device_BusReportedDeviceDesc
问题描述
对于连接到我的计算机的设备,我要检索设备属性总线报告的设备描述。为此,我使用
For devices attached to my machine I want to retrieve device-property Bus Reported Device Description. For this purpose I use function SetupDiGetDeviceProperty of Setup API. In devpkey.h I found the defintion DEVPKEY_Device_BusReportedDeviceDesc.
但是如果我使用 DEVPKEY_Device_BusReportedDeviceDesc >我在链接时收到无法解析的外部符号_DEVPKEY_Device_BusReportedDeviceDesc 。
But if I use DEVPKEY_Device_BusReportedDeviceDesc I receive unresolved external symbol _DEVPKEY_Device_BusReportedDeviceDesc while linking.
这是我的代码(仅包含用于重现问题的最少代码):
Here is my code (only included minimal code to reproduce issue):
#include "stdafx.h"
#include <Windows.h>
#include <devpropdef.h>
#include <devpkey.h>
int main()
{
DEVPROPKEY x = DEVPKEY_Device_BusReportedDeviceDesc;
return 0;
}
这是完整的错误代码:
错误LNK2001:无法解析的外部符号
_DEVPKEY_Device_BusReportedDeviceDesc
error LNK2001: unresolved external symbol _DEVPKEY_Device_BusReportedDeviceDesc
我该如何解决此问题?
推荐答案
要解决此问题,您需要包括 initguid.h 。这必须在 devpropdef.h 和 devpkey.h 之前。
To fix this issue you need to include initguid.h. This include must before devpropdef.h and devpkey.h.
#include "stdafx.h"
#include <initguid.h> // include before devpropdef.h
#include <Windows.h>
#include <devpropdef.h>
#include <devpkey.h>
int main()
{
DEVPROPKEY x = DEVPKEY_Device_BusReportedDeviceDesc;
return 0;
}
这篇关于未解析的外部符号_DEVPKEY_Device_BusReportedDeviceDesc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!