unresolved external symbol _DEVPKEY_Device_BusReportedDeviceDesc

别说谁变了你拦得住时间么 提交于 2020-06-16 05:07:48

问题


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.

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;
}

Here is the full error code:

error LNK2001: unresolved external symbol _DEVPKEY_Device_BusReportedDeviceDesc

How can I fix this issue ?


回答1:


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;
}


来源:https://stackoverflow.com/questions/47714380/unresolved-external-symbol-devpkey-device-busreporteddevicedesc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!