Results 1 to 20 of 35

Thread: How to get vendor id and product id of a USB device on windows system

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #19
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    6
    Thanked 348 Times in 333 Posts

    Default Re: How to get vendor id and product id of a USB device on windows system

    eg:

    Qt Code:
    1. SP_DEVICE_INTERFACE_DETAIL_DATA *pDetData = NULL;
    2. DWORD dwDetDataSize = sizeof (SP_DEVICE_INTERFACE_DETAIL_DATA) + 256;
    3.  
    4. pDetData = (_SP_DEVICE_INTERFACE_DETAIL_DATA_A*) malloc (dwDetDataSize);
    5. pDetData->cbSize = sizeof (SP_DEVICE_INTERFACE_DETAIL_DATA);
    6. bOk = SetupDiGetDeviceInterfaceDetail (hDevInfo, &ifcData, pDetData, dwDetDataSize, NULL, &devdata);
    To copy to clipboard, switch view to plain text mode 

    pDetData->DevicePath contains VID and PID in string form (eg. VID_xxxx&PID_xxxx), or you can use HidD_GetAttributes function in HID.DLL to extract these to a structure:

    typedef struct _HIDD_ATTRIBUTES {
    ULONG Size;
    USHORT VendorID;
    USHORT ProductID;
    USHORT VersionNumber;
    } HIDD_ATTRIBUTES, *PHIDD_ATTRIBUTES;
    Last edited by squidge; 29th May 2010 at 11:23.

Similar Threads

  1. Get the product/device name using QT library?
    By predatorz in forum Newbie
    Replies: 3
    Last Post: 14th January 2010, 03:53
  2. Vendor and Model Name from USB Devices
    By NoRulez in forum Qt Programming
    Replies: 6
    Last Post: 20th July 2009, 09:01
  3. Replies: 1
    Last Post: 19th September 2008, 15:43
  4. Problem whis open device in Windows
    By Pavka in forum Qt Programming
    Replies: 3
    Last Post: 19th November 2007, 10:13
  5. Ho to get the windows system directory with Qt4
    By rmagro in forum Qt Programming
    Replies: 4
    Last Post: 30th August 2007, 13:30

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.