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?
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.
If you're talking about a USB mass storage device without any assigned drive letter then it's just a volume without a mount point. You'll need to mount the volume before reading/writing it.
You can use the Volume Management Functions :
GUID
Here is a quickly-written example in C that list all the existing volumes, mount the unmounted ones and show some information about each volume :
I deliberetely simplify this example, but a volume can have multiple mount points (
volumePathName
is actually a multi-string). It uses this function to get the first available letter (after'C'
) to mount a drive :Yes. There are few cases a USB drive doesn't have a drive letter.
I believe yours is case #2.
In order to access files in a storage device, you need to force mount it as a storage device with drive letter. Unless you have a mount point, you cannot access the files i believe. This depends on the devices. Some devices (MTP) have internal settings to decide whether to detect as storage or not. You can explore the settings in the MTP device.
Otherwise you need to force all the storage device to mount through code.