I have written a program to display the available drives.
I want this program to work on all versions of Windows.
I have a problem, when I run the program with RunAsAdministrator, it does not display the sharing drive. How can I solve this problem?
#include <windows.h>
#include <direct.h>
#include <stdio.h>
#include <tchar.h>
TCHAR g_szDrvMsg[] = _T("A:\n"); //what does g_szDrvMsg do and what is TCHAR type?
int main(int argc, char* argv[]) {
ULONG uDriveMask = _getdrives(); //what is ULONG equivalent of C++ or it is just ULONG?
if (uDriveMask == 0)
{
printf("_getdrives() failed with failure code: %d\n",
GetLastError()); //So GetLastError retuns a sring or char*?
}
else
{
printf("The following logical drives are being used:\n");
while (uDriveMask) {
if (uDriveMask & 1)
printf(g_szDrvMsg);
++g_szDrvMsg[0];
uDriveMask >>= 1;
}
}
getchar();
}