a problem about SetupDiGetClassDevs & SetupDiEnumDeviceInterfaces

When I use DDK to develop a tool to check
USB devices, I met a problem,

hHardwareDevInfo = SetupDiGetClassDevs (
pUSBGUID,
NULL,
NULL,
(DIGCF_PRESENT ¦ DIGCF_INTERFACEDEVICE)
);

handle hHardwareDevInfo is VALID, but

check_bool = SetupDiEnumDeviceInterfaces (hHardwareDevInfo,
NULL,
pUSBGUID,
i, //variable
&deviceInfoData);

check_bool only returns 0.

simplly to say, windows finds the USB class, but windows
can not find anyone of the class.

who can give me the hint or the answer?

I think your pUSBGUID should be USB class GUID, but not interface GUID.
You should use the following method to enumerate USB class device.

hHardwareDevInfo = SetupDiGetClassDevs (
pUSBGUID,
NULL,
NULL,
DIGCF_PRESENT ) // only currently present device will be enumerated
);

check_bool = SetupDiEnumDeviceInfo(hHardwareDevInfo,
i,
&deviceInfoData);

Best Regards
Jack Huang



When I use DDK to develop a tool to check
USB devices, I met a problem,
---------------------------------------------
hHardwareDevInfo = SetupDiGetClassDevs (
pUSBGUID,
NULL,
NULL,
(DIGCF_PRESENT | DIGCF_INTERFACEDEVICE)
);
---------------------------------------------

handle hHardwareDevInfo is VALID, but
---------------------------------------------
check_bool = SetupDiEnumDeviceInterfaces (hHardwareDevInfo,
NULL,
pUSBGUID,
i, //variable
&deviceInfoData);
---------------------------------------------
check_bool only returns 0.

simplly to say, windows finds the USB class, but windows
can not find anyone of the class.

who can give me the hint or the answer?

Actually no, you want the usb interface guid. This gets enabled for all usb devices regardless of what device class the device is installed under. A USB device’s device class is not necessarily USB, for instance a HID device will be installed in the HID device class.

How did you initialize deviceInfoData? Did you set the size field before calling SetupDiEnumDeviceInfo? What does GetLastError return after it returns FALSE?

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Jack Huang
Sent: Thursday, October 04, 2007 8:17 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] a problem about SetupDiGetClassDevs & SetupDiEnumDeviceInterfaces

I think your pUSBGUID should be USB class GUID, but not interface GUID.
You should use the following method to enumerate USB class device.

hHardwareDevInfo = SetupDiGetClassDevs (
pUSBGUID,
NULL,
NULL,
DIGCF_PRESENT ) // only currently present device will be enumerated
);

check_bool = SetupDiEnumDeviceInfo(hHardwareDevInfo,
i,
&deviceInfoData);

Best Regards
Jack Huang



When I use DDK to develop a tool to check
USB devices, I met a problem,
---------------------------------------------
hHardwareDevInfo = SetupDiGetClassDevs (
pUSBGUID,
NULL,
NULL,
(DIGCF_PRESENT | DIGCF_INTERFACEDEVICE)
);
---------------------------------------------

handle hHardwareDevInfo is VALID, but
---------------------------------------------
check_bool = SetupDiEnumDeviceInterfaces (hHardwareDevInfo,
NULL,
pUSBGUID,
i, //variable
&deviceInfoData);
---------------------------------------------
check_bool only returns 0.

simplly to say, windows finds the USB class, but windows
can not find anyone of the class.

who can give me the hint or the answer?


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

hi, Jack & Doron,thanks alot for your reply.
let me describe my problem more clearly.

I plug a USB device on the PC, I know it is
NOW on the PC.

pUSBGUID is the GUID of this “USB device”,
not all kinds of USB device.

I also initialized deviceInfoData as following:

SP_INTERFACE_DEVICE_DATA deviceInfoData;
deviceInfoData.cbSize = sizeof(deviceInfoData);

after the steps I showed, I can not get
right response from SetupDiEnumDeviceInterfaces,
that is what I’m confused.

If the device does not register its interface, e.g. audio device, you
could not enumerate its interface. Maybe you could enumerate a serial
port first. If it works, then you could enumerate your usb device.

If you would like to enumerate a device without registered interface,
remove DIGCF_PRESENT in SetupDiGetClassDevs. However, since it does
not register it, you could not open it using CreateFile even if you
get its interface.

Regards, Mihs

Quoting xxxxx@gmail.com:

hi, Jack & Doron,thanks alot for your reply.
let me describe my problem more clearly.

I plug a USB device on the PC, I know it is
NOW on the PC.

pUSBGUID is the GUID of this “USB device”,
not all kinds of USB device.

I also initialized deviceInfoData as following:

SP_INTERFACE_DEVICE_DATA deviceInfoData;
deviceInfoData.cbSize = sizeof(deviceInfoData);

after the steps I showed, I can not get
right response from SetupDiEnumDeviceInterfaces,
that is what I’m confused.


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


This message was sent using IMP, the Internet Messaging Program.

You can call GetLastError() to get the error code if it enumerated fail.
This can help to analyze the failure reason.


> hi, Jack & Doron,thanks alot for your reply.
> let me describe my problem more clearly.
>
> I plug a USB device on the PC, I know it is
> NOW on the PC.
>
> pUSBGUID is the GUID of this “USB device”,
> not all kinds of USB device.
>
> I also initialized deviceInfoData as following:
> ------------------------------------------------------------------------
> SP_INTERFACE_DEVICE_DATA deviceInfoData;
> deviceInfoData.cbSize = sizeof(deviceInfoData);
> -------------------------------------------------------------------------
> after the steps I showed, I can not get
> right response from SetupDiEnumDeviceInterfaces,
> that is what I’m confused.
>
>