0

I am attempting to list all devices currently plugged into the computer/laptop using Win32 API. When I say devices I mean; headphones, usb storage devices, HDMI connections(a TV or projector), a printer and etc.

Whats the best Native Win32 function to use to simply detect what devices are plugged in and what type they are?

Would the functions:

SetupDiClassGuidsFromNameA("Ports", 0, 0, &RequiredSize);
SetupDiClassGuidsFromNameA("Ports", (_GUID*)buf, RequiredSize*sizeof(GUID), &RequiredSize);

and

SetupDiEnumDeviceInfo(DeviceInfoSet,numDev,&DeviceInfoData); 

be best?

4

1 に答える 1

1

Yes, the Setup API is the way to go to enumerate devices in C++.

Here's a simple sample: http://www.codeproject.com/Articles/6445/Enumerate-Installed-Devices-Using-Setup-API

于 2012-12-30T04:46:41.640 に答える