Prev Previous Post   Next Post Next

Enumerating Interfaces

Posted: 02-20-2004, 05:36 PM
Dear Group:

I'm trying to enumerate a list of all devices belonging to a given
class and for each device, enumerate a list of all interfaces
associated with that device.

I've poured over the SetupDIxxx documentation & am now thoroughly
confused. Here's a sample of the code I've tried:


GUID ClassGuid = CLASS_GUID;
GUID InterfaceGuid1 = INTERFACE_GUID_1;
GUID InterfaceGuid2 = INTERFACE_GUID_2;

DWORD DeviceListLoad()
{
HDEVINFO hDeviceInfoSet;
DWORD DeviceEnum;
DWORD InterfaceEnum;
LPDEVICE lpDevice;
DWORD LastError;

// Get a list of all devices which have CMS Version 5.0 GUID
hDeviceInfoSet = SetupDiGetClassDevs(
&ClassGuid,
NULL, // no enumerator
NULL, // Define no UI window
DIGCF_PRESENT // Only Devices present
);

for (DeviceEnum=0;;DeviceEnum++)
{
SP_DEVINFO_DATA DeviceInfoData;
ZeroMemory(&DeviceInfoData, sizeof(SP_DEVINFO_DATA));
DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);

// Get the DeviceInfoData
if (FALSE == SetupDiEnumDeviceInfo(
hDeviceInfoSet,
DevEnum,
&DeviceInfoData))
{
LastError = GetLastError();
if (ERROR_NO_MORE_ITEMS = LastError)
// At the end of the device set
break;
else
// A real error happened
return LastError;
}
for (InterfaceEnum = 0; ; InterfaceEnum++)
{
SP_DEVICE_INTERFACE_DATA DeviceInterfaceData;
ZeroMemory(&DeviceInterfaceData,
sizeof(SP_DEVICE_INTERFACE_DATA));
DeviceInterfaceData.cbSize =
sizeof(SP_DEVICE_INTERFACE_DATA);


// Get an interface
if (FALSE == SetupDiEnumDeviceInterfaces(
hDeviceInfoSet,
lpDeviceInfoData,
==>> &Guid, //IN WHAT GOES HERE???
InterfaceEnum,
&DeviceInterfaceData))
{
LastError = GetLastError();
if (ERROR_NO_MORE_ITEMS = LastError)
// At the end of the list
break;
else
// A real error happened.
return LastError;
}

//
// OK We found a device of our class
// which containes an InterfaceGuid.
if (DeviceInterfaceData.InterfaceClassGuid ==
InterfaceGuid1)
DoSomethingToDevice(...);
else if (DeviceInterfaceData.InterfaceClassGuid ==
InterfaceGuid2)
DoSomethingDifferentToDevice(...);
else
DontDoAnything();

}
}

SetupDiDestroyDeviceInfoList(hDeviceInfoSet);
return ERROR_SUCCESS;
}


OK so this can't work since I'm looking for an interface GUID & can't
supply one.

So how can I get a list of interfaces belonging to a device of a given
class?

Thanks for your help in advance
Max
Reply With Quote

Responses to "Enumerating Interfaces"

 
LinkBack Thread Tools Display Modes
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


Similar Threads
Thread Thread Starter Forum Replies Last Post
switching between Basic & Aero interfaces foreverLaur Windows Vista Administration 1 02-03-2007 08:35 PM
Enable/Disable Network Interfaces Stefan Helmig Windows Vista Networking & Sharing 1 01-16-2007 09:08 AM
Enumerating Reg Key and Value xpacifica Windows XP WMI 1 01-16-2006 09:10 PM
Enumerating LSA ignacio Windows XP WMI 2 10-04-2005 08:16 PM
Merging multiple user interfaces T Windows XP Configuration & Management 1 06-26-2004 08:00 PM