Datatype Misalignment
-
Can someone explain why I get a Datatype Misalignment error message when I use the ::GetDiskFreeSpaceEx function? I am getting the correct data returned but when I try to save any of the values to a variable I get this error. I've tried delcaring the variable as ULONGLONG or __ui64, but nothing works. What datatype should the variable be? and should I save the LowPart or QuadPart? I wont ever see more than 2GB of memory space. Does anyone have an example for eMbedded VC++?:confused: Paul Jahans
-
Can someone explain why I get a Datatype Misalignment error message when I use the ::GetDiskFreeSpaceEx function? I am getting the correct data returned but when I try to save any of the values to a variable I get this error. I've tried delcaring the variable as ULONGLONG or __ui64, but nothing works. What datatype should the variable be? and should I save the LowPart or QuadPart? I wont ever see more than 2GB of memory space. Does anyone have an example for eMbedded VC++?:confused: Paul Jahans
Hi, did a quick check on my system and it works fine. Since you didn't post any code, I have no idea why you got a datatype misalignment.
TCHAR buff[200]; ULARGE_INTEGER lFreeCaller, lTotBytes , lTotFreeBytes ; ::GetDiskFreeSpaceEx (NULL, &lFreeCaller, &lTotBytes, &lTotFreeBytes); swprintf(buff, _T("%u mb free for caller, %u total mbytes, %u total free mbytes"), lFreeCaller.QuadPart >> 20 , lTotBytes.QuadPart >> 20, lTotFreeBytes.QuadPart>> 20 ); MessageBox(0, buff, _T("Info"), 0); unsigned __int64 test1 = lFreeCaller.QuadPart; unsigned __int64 test2 = lTotBytes.QuadPart; unsigned __int64 test3 = lTotFreeBytes.QuadPart; int mb1 = (test1 >> 20); int mb2 = (test2 >> 20); int mb3 = (test3 >> 20); swprintf(buff, _T("%u mb free for caller, %u total mbytes, %u total free mbytes"), mb1, mb2, mb3); MessageBox(0, buff, _T("Info"), 0);
Not sure why the first messagebox reports 0 MB and the second shows 15 MB for Total number of bytes, but Im sure you can investigate that further if you're interested in that value. HTH “Our solar system is Jupiter and a bunch of junk” - Charley Lineweaver 2002