Ladies and Gentlemen Coders,
I'm working with the code below:
int GetDrives(void)
{
wchar_t LogicalDrives[MAX_PATH] = {0};
DWORD r = GetLogicalDriveStringsW(MAX_PATH, LogicalDrives);
if ( r == 0 )
{
printf("Failed to get drive names. %ld", GetLastError());
return 1;
}
int NumDriveCount = 0;
if ( r > 0 && r <= MAX_PATH)
{
wchar_t *SingleDrive = LogicalDrives;
while(*SingleDrive){
printf("Local Drives: %s Drive Size: %ls", SingleDrive, );
SingleDrive += wcslen(SingleDrive) +1;
NumDriveCount++;
}
}
printf("Total Drives: %i\n", NumDriveCount);
}
#pragma comment(lib, "user32.lib")
char DRIVE_TYPE[1];
int GetDriveFree(char *DRIVE[])
{
//int GetDriveFree(void) {
unsigned __int64 freeCall,
total,
free;
int r = GetDiskFreeSpaceExW(L"C:\\", (PULARGE_INTEGER) &freeCall,
(PULARGE_INTEGER) &total, (PULARGE_INTEGER) &free);
if (r == 0) {
wprintf(L"Failed to get free disk space %ld", GetLastError());
return 1;
}
wprintf(L"Available space to caller: %I64u MB\n", freeCall / (1024*1024));
wprintf(L"Total space: %I64u MB\n", total / (1024*1024));
wprintf(L"Free space on drive: %I64u MB\n", free / (1024*1024));
return 0;
}
And as you can see on line:
printf("Local Drives: %s Drive Size: %ls", SingleDrive, );
SingleDrive += wcslen(SingleDrive) +1;
NumDriveCount++;
I have tried running
//ALSO LINK THIS TO FREE SPACE
//GetDriveFree(LogicalDrives);
printf("This is the drive: %s\n", LogicalDrives);
//GetDriveFree(LogicalDrives);
printf("This is a drive test %s\n", LogicalDrives);
LogicalDrives = DRIVE_TYPE;
SingleDrive += wcslen(SingleDrive) +1;
And, for some reason I can't for the life of me get this to work. I am beginning in C and have burned through 3 books in the last few days. Can someone maybe explain as to why this does not work? The rest of the code does work, but it's beginning to walk without holding onto something that is getting me. I'd greatly appreciate it.