IN PSP_DEVINFO_DATA DeviceInfoData, //I used the deviceinfo
returned by the SetupDiEnumDeviceInfo here
Try passing NULL here.
The most confusing part is the InterfaceClassGuid.Is that the Guid of
the device class,or,is there one Guid for each individual device
interface?If so,where to get the Guids of each individual interface?
A very good question and one that's probably at the heart of my problem
as well. ISTM that those functions are concerned more with device
management (installation/removal) than with actually providing access
to the devices themselves. The link between the two is provided by
SetupDiEnumDeviceInterfaces() and SetupDiGetDeviceInterfaceDetail(). We
use the following function to obtain a list of class interfaces for a
given GUID then for each member it obtains the CreateFile() compatible
path:
typedef std::vector<AnsiString> TClassDeviceList;
TClassDeviceList
doEnumSpecificClass( GUID ClassGUID,
HDEVINFO DeviceInfoSet )
{
// Added for newsgroup posting
boost::scoped_array<BYTE> wibble2( new BYTE[ 10240 ] );
TClassDeviceList result;
SP_DEVICE_INTERFACE_DATA devIntData;
devIntData.cbSize=sizeof( devIntData );
DWORD member=0;
while( SetupDiEnumDeviceInterfaces( DeviceInfoSet,
NULL,
&ClassGUID,
member,
&devIntData ) )
{
SP_DEVICE_INTERFACE_DETAIL_DATA devIntDetailData;
devIntDetailData.cbSize=sizeof( devIntDetailData );
DWORD reqdevIntDetailDataSize=0;
SP_DEVINFO_DATA deviceInfoData;
deviceInfoData.cbSize=sizeof( deviceInfoData );
PSP_DEVICE_INTERFACE_DETAIL_DATA ptr=
reinterpret_cast<PSP_DEVICE_INTERFACE_DETAIL_DATA>(
wibble2.get() );
ptr->cbSize=sizeof( SP_DEVICE_INTERFACE_DETAIL_DATA );
if( SetupDiGetDeviceInterfaceDetail( DeviceInfoSet,
&devIntData,
ptr,
10240,
&reqdevIntDetailDataSize,
&deviceInfoData ) )
{
result.push_back( ptr->DevicePath ); // <<<< Success!
}
++member;
}
return result;
}