From: USB Device User on
Yes, I did. I can pass Null to enumerate all devices. But which api call
should I use to get VID/PID?

"Pavel A." wrote:

> "USB Device User" <USBDeviceUser(a)discussions.microsoft.com> wrote in message
> news:60FB1C84-C1E3-42EA-9848-9B67D9F0D96F(a)microsoft.com...
> > I tried SetupDi functions. It is easy for HID to get GUID and VID/PID. But
> > for general USB device, how can I get GUID and VID/PID from the api calls?
>
> Have you tried SetupDiGetClassDevs ?
> -- pa
>
> > "Philip Ries [MSFT]" wrote:
> >
> >> One way is via Setup API (it's a managed API so you will have to PInvoke
> >> it). Start with function SetupDiGetClassDevs.
> >>
> >> USB Device User wrote:
> >> > BTW, I am trying to use winapi calls not wmi.
> >> >
> >> > "USB Device User" wrote:
> >> >
> >> >> I have a USB printer and I know its vendor ID and product ID. How can
> >> >> I know
> >> >> it is connected from my C# application?
> >> .
> >>
From: Maxim S. Shatskih on
> Yes, I did. I can pass Null to enumerate all devices. But which api call
> should I use to get VID/PID?

SetupDiGetDeviceRegistryProperty returns a hardware ID.

And there is a doc page about how the USB HW IDs are composed from VID/PID.

--
Maxim S. Shatskih
Windows DDK MVP
maxim(a)storagecraft.com
http://www.storagecraft.com

From: Tim Roberts on
"Maxim S. Shatskih" <maxim(a)storagecraft.com.no.spam> wrote:
>
>> Yes, I did. I can pass Null to enumerate all devices. But which api call
>> should I use to get VID/PID?
>
>SetupDiGetDeviceRegistryProperty returns a hardware ID.
>
>And there is a doc page about how the USB HW IDs are composed from VID/PID.

Is there? The format has not changed since Windows 95 OSR2, but I thought
it was officially undocumented. Do you remember which page this is on?
--
Tim Roberts, timr(a)probo.com
Providenza & Boekelheide, Inc.
From: Wilhelm Noeker on
Tim Roberts wrote:
> "Maxim S. Shatskih" <maxim(a)storagecraft.com.no.spam> wrote:
>>> Yes, I did. I can pass Null to enumerate all devices. But which api call
>>> should I use to get VID/PID?
>> SetupDiGetDeviceRegistryProperty returns a hardware ID.
>>
>> And there is a doc page about how the USB HW IDs are composed from VID/PID.
>
> Is there? The format has not changed since Windows 95 OSR2, but I thought
> it was officially undocumented. Do you remember which page this is on?

I recently stumbled into it in a section titled "Enumeration of USB
Composite Devices":

http://msdn.microsoft.com/en-us/library/ff537109%28VS.85%29.aspx
From: Maxim S. Shatskih on
> Is there? The format has not changed since Windows 95 OSR2

There was an MSDN page somewhere which documents the PnP IDs layout for all common buses.

--
Maxim S. Shatskih
Windows DDK MVP
maxim(a)storagecraft.com
http://www.storagecraft.com