I am trying to write an application that will detect all the USB devices connected to my computer. For this I have declared GUID and called the following functions to get the information about devices connected.


LPGUID guid;
HidD_GetHidGuid(guid);

HDEVINFO hDevInfo;

hDevInfo = SetupDiGetClassDevs(guid,NULL,NULL,DIGCF_PRESENT |

DIGCF_INTERFACEDEVICE);


But it give the following error ….

error LNK2019: unresolved external symbol _imp__SetupDiGetClassDevsA@16 referenced in function "public: void __thiscall

error LNK2019: unresolved external symbol "void __stdcall HidD_GetHidGuid(struct _GUID *)"

fatal error : LNK1120: 2 unresolved externals

I don’t understand that where am I making mistake? I have include the following header files :

Hidclass.h
Setupapi.h
Hidsdi.h


Can you please tell me what mistake am I making?

Recommended Answers

All 3 Replies

you are missing the libraries that contain those functions. Get the libs from wherever you got those header files.

Finally I got it I have included hdi.lib,setupapi.lib
I got these files from windows ddk
now it's compiling without any error.

thank you

include setupapi.lib in your linker if you have included the headers from ddk

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.