1

I'm using qt on Windows. My program need to know vendor id and product id of plugged usb flash drive.

I was trying to implement example from this topic, but I'm getting segmentation fault on WinUsb_Initialize function.

This is my code:

HANDLE hDevice = CreateFileA("\\\\.\\PhysicalDrive1", GENERIC_WRITE | GENERIC_READ ,
     FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0);

if(hDevice == INVALID_HANDLE_VALUE)
{
    qDebug() << "hDevice - INVALID_HANDLE_VALUE";
}
else
{
    qDebug() << "hDevice handle ok";
    PWINUSB_INTERFACE_HANDLE phWinUSBHandle;
    BOOL result = false;
    result = WinUsb_Initialize(hDevice, phWinUSBHandle); //seg
}

I need phWinUSBHandle to use WinUsb_GetDescriptor function.

I'll be very grateful for any help. Maybe someone knows some alternative way to get vendor id and product id in windows?

Community
  • 1
  • 1
sparkyfx
  • 11
  • 2

1 Answers1

1

Have you referred libusb library ? It might help you.

Mandar Pande
  • 12,250
  • 16
  • 45
  • 72
  • After reading [this topic](http://comments.gmane.org/gmane.comp.lib.libusb.devel.windows/4417), I'm afraid that libusb-win32 won't help me. I'll try libusb-win32 later. Thank you for your replay. – sparkyfx Aug 08 '12 at 13:55