Using the code below in order to get names of my drives:
const DWORD buffer_length = sizeof(DWORD)*CHAR_BIT;
WCHAR buffer[buffer_length] = {0};
GetLogicalDriveStrings(buffer_length,buffer);
std::set<wchar_t> drives_letters;
for(auto e : buffer)
{
drives_letters.insert(e);
}
I’m getting following output as a result (looping over drives_letters):
: //what on earth is this?
C
D
E
F
G
I
\ //and what on earth is this?
GetLogicalDriveStringsreturns strings in the formC:\. This can be inferred from this documentation passage:Since you are putting these characters into a set, which disallows duplicates, you end up with all the different drive letters plus one copy of a double colon and a backslash. And the reason that the colon prints first and the backslash last is that
std::setis inherently ordered, so the ASCII codes of each character decide.