954,506 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to Detect USB devices connected

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?

anderson
Newbie Poster
11 posts since Sep 2004
Reputation Points: 10
Solved Threads: 0
 

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

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

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

anderson
Newbie Poster
11 posts since Sep 2004
Reputation Points: 10
Solved Threads: 0
 

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

shazzzz...
Newbie Poster
1 post since Sep 2011
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You