char szLogicalDrives[MAX_PATH];
size_t size = strlen(szLogicalDrives) + 1;
wchar_t* text = new wchar_t[size];
You cannot get a valid answer from
strlen
called on an uninitialised array. You may get zero, or some random number. Either way, the rest of the code will not give valid results.