Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WinAPI calls to access USB storage which has no drive letter?

I've noticed, that some USB storage devices don't register in Windows as regular drives, in that they don't even get assigned a drive letter. Therefore, I can't apparently access them using the standard file operations C API.

What are the WinAPI calls I can use to do some normal file operations on those strange devices - so:

  • find/enumerate those devices at all,
  • browse the file/directory tree on the device and get some file stats (size, modification date, etc.),
  • read/write contents of the files,
  • create/delete files/directories?

Also, what are the general keywords by which those kinds devices/protocol are known/called?

like image 436
akavel Avatar asked Apr 30 '13 08:04

akavel


People also ask

How do I get a USB drive letter?

By default, Windows gave my portable USB drive the letter H. If your drive has no letter or you want to change it, then right-click in the white space to the right of the drive letter and choose Change Drive Letter and Paths. Click the Change button in the dialog box and then pick a new letter from the drop-down list.

How do I access USB mass storage device?

On Device Manager screen, expand the entry for Universal Serial BUS Controllers > right-click on the USB Drive and click on Enable. Similarly, you can use the above steps to enable USB Mass Storage Device, if you are unable to access an external storage device on your computer.


1 Answers

If you're talking about mobile devices that appears like mounted volumes but without any mounted points, well they are called Windows Portable Devices and they are not mounted volumes.

Windows doesn't access the file system directly, it only communicates with them through the Media Transfer Protocol (MTP) or Picture Transfert Protocol (PTP) and creates a shell namespace extension to present a virtual folder to the user.

If you want to communicate with these kind of devices, then you most probably want to use the WPD API.

like image 150
zakinster Avatar answered Sep 28 '22 00:09

zakinster