Reputation: 25928
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?
Upvotes: 0
Views: 1626
Reputation: 4458
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
Upvotes: 1