对于连接到我的机器的设备,我想检索设备属性总线报告设备描述。为此我使用函数设置DiGetDeviceProperty https://msdn.microsoft.com/library/windows/hardware/ff551963 of 设置API https://learn.microsoft.com/en-us/windows-hardware/drivers/install/setupapi. In 开发密钥.h我找到了定义DEVPKEY_Device_BusReportedDeviceDesc.
但如果我使用DEVPKEY_Device_BusReportedDeviceDesc我收到无法解析的外部符号 _DEVPKEY_Device_BusReportedDeviceDesc链接时。
这是我的代码(仅包含重现问题的最少代码):
#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
我该如何解决这个问题?
要解决此问题,您需要包括初始化向导.h。这包括必须之前devpropdef.h and 开发密钥.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;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)