未解析的外部符号_DEVPKEY_Device_BusReportedDeviceDesc [英] unresolved external symbol _DEVPKEY_Device_BusReportedDeviceDesc

查看:389
本文介绍了未解析的外部符号_DEVPKEY_Device_BusReportedDeviceDesc的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于连接到我的计算机的设备,我要检索设备属性总线报告的设备描述。为此,我使用 SetupDiGetDeviceProperty /docs.microsoft.com/zh-CN/windows-hardware/drivers/install/setupapi rel = nofollow noreferrer>安装API 。在 devpkey.h 中,我找到了定义 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆