|
From: Stephan M. <ste...@we...> - 2007-05-28 10:58:11
|
See http://www.nabble.com/Error-compiling-test-program-tf3508594.html#a9870106 > > > Hi! > > I have just started to use the libusb-win32, I am trying to get it to work > with borland c-builder 6 on win XP. > If I run the test application testlibusb-win.exe It works just fine but when > I take the code and change it for the c-builder I get a problem no mather > what I do I cant read the configure descriptor in the usb_device struct the > code that I am using is this: > > __fastcall TForm1::TForm1(TComponent* Owner) > : TForm(Owner) > { > //these method is called whene the GUI is created > usb_init(); > usb_find_busses(); > usb_find_devices(); > } > //--------------------------------------------------------------------------- > > void __fastcall TForm1::Button1Click(TObject *Sender) > { > // whene button1 on the gui is pushed this method is executed > version = usb_get_version(); > > if(version) > { > line = "DLL version:\t"; > line += version->dll.major; > line += "."; > line += version->dll.minor; > line += "."; > line += version->dll.micro; > line += "."; > line += version->dll.nano; > > this->Memo1->Lines->Add(line); > > line = "Driver version:\t"; > line += version->driver.major; > line += "."; > line += version->driver.minor; > line += "."; > line += version->driver.micro; > line += "."; > line += version->driver.nano; > > this->Memo1->Lines->Add(line); > } > > this->Memo1->Lines->Add("bus/device\t idVendor/idProduct"); > > for (bus = usb_get_busses(); bus; bus = bus->next) { > for (dev = bus->devices; dev; dev = dev->next) { > int ret, i; > char string[256]; > usb_dev_handle *udev; > > line = bus->dirname; > line += "/"; > line += dev->filename; > line += "\t"; > line += IntToHex(dev->descriptor.idVendor,1); > line += "/"; > line += IntToHex(dev->descriptor.idProduct,1); > > this->Memo1->Lines->Add(line); > > udev = usb_open(dev); > > if (udev) { > if (dev->descriptor.iManufacturer) { > ret = usb_get_string_simple(udev, dev->descriptor.iManufacturer, > string, sizeof(string)); > if (ret > 0) { > line = "- Manufacturer : "; > line += AnsiString(string); > this->Memo1->Lines->Add(line); > } else { > this->Memo1->Lines->Add("- Unable to fetch manufacturer > string"); > } > } > > if (dev->descriptor.iProduct) { > ret = usb_get_string_simple(udev, dev->descriptor.iProduct, > string, > sizeof(string)); > if (ret > 0) { > line = "- Product : "; > line += AnsiString(string); > this->Memo1->Lines->Add(line); > } else { > this->Memo1->Lines->Add("- Unable to fetch product string"); > } > } > > if (dev->descriptor.iSerialNumber) { > ret = usb_get_string_simple(udev, dev->descriptor.iSerialNumber, > string, sizeof(string)); > if (ret > 0) { > line = "- Serial number : "; > line += AnsiString(string); > this->Memo1->Lines->Add(line); > } else { > this->Memo1->Lines->Add("- Unable to fetch serial number > string"); > } > } > > usb_close (udev); > } > > if (!dev->config) { > this->Memo1->Lines->Add(" Couldn't retrieve descriptors"); > continue; > } > > i = 0; > for (i = 0; i < dev->descriptor.bNumConfigurations; i++) > print_configuration(&dev->config[i]); > } > } > } > //--------------------------------------------------------------------------- > void TForm1::print_configuration(struct usb_config_descriptor *config) > { > int i; > //!!!!!!!The error occur here!!!!!!!!// > unsigned short wtlength = config->wTotalLength; //<======== When I am > trying to get any variable in the configure descriptor > > line = " wTotalLength: "; > line += wtlength; > > this->Memo1->Lines->Add(line); > > } > > the error that I get is accsses violation. > > -- > View this message in context: http://www.nabble.com/libusb-with-borland-c-builder-tf3827103.html#a10833779 > Sent from the LibUSB Dev - Win32 mailing list archive at Nabble.com. > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Libusb-win32-devel mailing list > Lib...@li... > https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel > _______________________________________________________________ SMS schreiben mit WEB.DE FreeMail - einfach, schnell und kostenguenstig. Jetzt gleich testen! http://f.web.de/?mc=021192 |