[wdmaudiodev] Re: SetupDiEnumDeviceInterfaces() fails - what could be the problem?

  • From: "Don Bell" <0dbell@xxxxxxxxx>
  • To: wdmaudiodev@xxxxxxxxxxxxx
  • Date: Sat, 14 Apr 2007 23:41:36 -0500

On 4/14/07, Don Bell <0dbell@xxxxxxxxx> wrote:
After successfully registering a custom device interface in an MSVAD
based device driver, I tried using SetupDiEnumDeviceInterfaces() in a
user mode application to verify that I understood the concept.

In the user mode test program I wrote:

====================================
// Get handle to relevant device information set
HDEVINFO info = SetupDiGetClassDevs(
 pGuid,
 NULL,
 NULL,
 DIGCF_PRESENT | DIGCF_INTERFACEDEVICE);

if (info == INVALID_HANDLE_VALUE)
{
 printf("No HDEVINFO available for this GUID\n");
 return NULL;
}

// Get interface data for the requested instance
SP_INTERFACE_DEVICE_DATA ifdata;
ifdata.cbSize = sizeof(ifdata);

if (!SetupDiEnumDeviceInterfaces(
     info,      // HDEVINFO DeviceInfoSet
     NULL,      // PSP_DEVINFO_DATA DeviceInfoData
     pGuid,     // CONST GUID * InterfaceClassGuid
     instance,  // DWORD MemberIndex
     &ifdata))  // PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData

{
 ULONG lastError = GetLastError();
 printf("No SP_INTERFACE_DEVICE_DATA for this GUID instance\n");
 printf("GetLastError() returns: %d\n", lastError);

 SetupDiDestroyDeviceInfoList(info);
 return NULL;
}
====================================

The pGuid contains the same exact GUID that was passed as the 2nd
parameter to IoRegisterDeviceInterface() in the device driver's
StartDevice().

I verified that this GUID exists in the registry under:

HKLM\SYSTEM\CurrentControlSet\Control\DeviceClasses

But nevertheless, while SetupDiGetClassDevs() succeeds,
SetupDiEnumDeviceInterfaces() fails with GetLastError() code of 259
(ERROR_NO_MORE_ITEMS).

Why?
What could possibly be the problem in such trivial call?
What is the "trick" that I am missing in properly using this function?

BTW, I also tried using a different GUID - the ClassGUID in the .inf
file, in case I misunderstood the meaning of the 3rd parameter to
SetupDiEnumDeviceInterfaces() but that one failed too. I am stumped.
How does one troubleshoot a problem like that?

Thanks,
Don


Duh! 3.9815726 milliseconds after I posted this question, I found the answer:

The GUID to be used SetupDiEnumDeviceInterfaces() should *not* be the
same GUID that was used to IoRegisterDeviceInterface().

Instead, the GUIDs for the various KSCATEGORY listed in the .inf file
should be used.

Tricky.

Posted for the benefit of future newbies like me. :-)

Don
******************

WDMAUDIODEV addresses:
Post message: mailto:wdmaudiodev@xxxxxxxxxxxxx
Subscribe:    mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=subscribe
Unsubscribe:  mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=unsubscribe
Moderator:    mailto:wdmaudiodev-moderators@xxxxxxxxxxxxx

URL to WDMAUDIODEV page:
http://www.wdmaudiodev.com/

Other related posts: