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