This question already has an answer here:
- Enumerating all available drive letters in Windows 5 answers
How can I get the removable drive letter so that I could create a path and copy data from PC to the removable drive?
Currently I'm using
_getcwd(buff,b_SIZE);
MessageBox(buff);
strncpy(Root,buff,3);
I have no problem if I run my software directly from the USB and it will returns to me either D: or E:, which depends on the availability I guess. But my problem is I have to run my USB program from the PC which is of course the PC's program installed in C drive, and therefore this _getcwd
will give me C:\ drive letter. That's why I'm looking for if there's a way to check the current removable drive letter instead.
This is the nearest I could find for my question: Detect removable drive (e.g. USB flash drive) C/C++