Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Hardware & Devices
  4. How to get USB device address?

How to get USB device address?

Scheduled Pinned Locked Moved Hardware & Devices
sharepointdatabasetutorialquestion
2 Posts 2 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    linshi
    wrote on last edited by
    #1

    for (index=0; SetupDiEnumDeviceInterfaces(deviceInfo, 0, (LPGUID)&GUID_CLASS_USB, index, &DeviceInterfaceData); index++) { memset(tempstr, 0, 1024); deviceDetailData = (PSP_DEVICE_INTERFACE_DETAIL_DATA)tempstr; deviceDetailData->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA); SetupDiGetDeviceInterfaceDetail(deviceInfo, &DeviceInterfaceData, deviceDetailData, 1024, &requiredLength, NULL); hUSBHandle = CreateFile(deviceDetailData->DevicePath, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); CloseHandle(hUSBHandle); } I would like enumerate all usb devices and get their device address. How could I do? I counld use the following codes to get DeviceAddress. DeviceIoControl(hHubDevice,IOCTL_USB_GET_NODE_CONNECTION_INFORMATION,connectionInfo, nBytes,connectionInfo,nBytes,&nBytes, NULL) ; But how to get device address without through usbHub. Thanks and regards

    M 1 Reply Last reply
    0
    • L linshi

      for (index=0; SetupDiEnumDeviceInterfaces(deviceInfo, 0, (LPGUID)&GUID_CLASS_USB, index, &DeviceInterfaceData); index++) { memset(tempstr, 0, 1024); deviceDetailData = (PSP_DEVICE_INTERFACE_DETAIL_DATA)tempstr; deviceDetailData->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA); SetupDiGetDeviceInterfaceDetail(deviceInfo, &DeviceInterfaceData, deviceDetailData, 1024, &requiredLength, NULL); hUSBHandle = CreateFile(deviceDetailData->DevicePath, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); CloseHandle(hUSBHandle); } I would like enumerate all usb devices and get their device address. How could I do? I counld use the following codes to get DeviceAddress. DeviceIoControl(hHubDevice,IOCTL_USB_GET_NODE_CONNECTION_INFORMATION,connectionInfo, nBytes,connectionInfo,nBytes,&nBytes, NULL) ; But how to get device address without through usbHub. Thanks and regards

      M Offline
      M Offline
      mmhu
      wrote on last edited by
      #2

      how does the deviceDetailData->DevicePath look like??? I use GetLogicalDrives to retrieve all removable drives and get: A:\, I:\...............(I:\ is my USB drive mount point). But my application needs to determine which drive letter (mount point) is for the USB. Then use this mount point to access files stored in the root directory of the USB flash drive. hUSBHandle = CreateFile(deviceDetailData->DevicePath, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); CloseHandle(hUSBHandle); ReadFile returns false using this handle.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups