TechTalkz.com Home

Go Back   Windows Help & Support > Windows Device Drivers
Home Register Forum Rules FAQ User Blogs Gallery

Detect a USB Device

Windows Device Drivers


Reply
 
LinkBack Thread Tools Display Modes
Old 05-25-2010, 06:30 PM   #1
USB Device User
Guest
 
Posts: n/a
Default Detect a USB Device

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?

Advertisement

  Reply With Quote
Old 05-25-2010, 07:30 PM   #2
USB Device User
Guest
 
Posts: n/a
Default RE: Detect a USB Device

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?

  Reply With Quote
Old 05-25-2010, 07:30 PM   #3
Philip Ries [MSFT]
Guest
 
Posts: n/a
Default Re: Detect a USB Device

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?

  Reply With Quote
Old 05-25-2010, 08:30 PM   #4
USB Device User
Guest
 
Posts: n/a
Default Re: Detect a USB Device

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?

"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?

> .
>

  Reply With Quote
Old 05-25-2010, 10:30 PM   #5
Pavel A.
Guest
 
Posts: n/a
Default Re: Detect a USB Device

"USB Device User" <USBDeviceUser@discussions.microsoft.com> wrote in message
news:60FB1C84-C1E3-42EA-9848-9B67D9F0D96F@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?

>> .
>>

  Reply With Quote
Old 05-25-2010, 10:30 PM   #6
USB Device User
Guest
 
Posts: n/a
Default Re: Detect a USB Device

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@discussions.microsoft.com> wrote in message
> news:60FB1C84-C1E3-42EA-9848-9B67D9F0D96F@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?
> >> .
> >>

  Reply With Quote
Old 05-26-2010, 10:30 AM   #7
Maxim S. Shatskih
Guest
 
Posts: n/a
Default Re: Detect a USB Device

Advertisement
> 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@storagecraft.com
http://www.storagecraft.com


Advertisement

  Reply With Quote
Reply

Thread Tools
Display Modes



< Windows Help - MS Office Help >


New To Site? Need Help?

All times are GMT. The time now is 09:51 PM.


vBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright © 2005-2008, TechTalkz.com. All Rights Reserved - Privacy Policy
Valid XHTML 1.0 Transitional