Gamble
April 13th, 1999, 02:23 AM
I'm having a bit of trouble with some code that's supposed to determine whether GetDiskFreeSpaceEx is present on the user's system. I attempt to load the KERNEL32 DLL, then query it for the address of this function, but while I'm sure it's there (on this box at least) I always obtain NULL on my call to GetProcAddress(). I suspect I may not be using the correct identifier, but I can't find the .def file for this DLL. The code that's causing me problems is:
// It's necessary to determine whether or not the GetDiskFreeSpaceEx()
// function is present. This means KERNEL32.DLL must be loaded.
hKernel32 = LoadLibrary("KERNEL32.DLL");
// Bail out if the DLL cannot be found..this is bad
if (hKernel32 == NULL)
{
AfxMessageBox("KERNEL32.DLL could not be found.", MB_ICONSTOP);
return(FALSE);
}
// Retrieve the function pointer and free the library again
pGetDiskFreeSpaceEx = GetProcAddress(hKernel32, "GetDiskFreeSpaceEx");
FreeLibrary(hKernel32);
// If the DLL contains this function, then it can safely be called
if (pGetDiskFreeSpaceEx != NULL)
if (GetDiskFreeSpaceEx((LPCSTR)szDest, &pqwFreeCaller, &pqwTot, &pqwFree))
{
if (nSum <= pqwFreeCaller.QuadPart)
return(TRUE);
else
return(FALSE);
}
Can anyone help with this?
// It's necessary to determine whether or not the GetDiskFreeSpaceEx()
// function is present. This means KERNEL32.DLL must be loaded.
hKernel32 = LoadLibrary("KERNEL32.DLL");
// Bail out if the DLL cannot be found..this is bad
if (hKernel32 == NULL)
{
AfxMessageBox("KERNEL32.DLL could not be found.", MB_ICONSTOP);
return(FALSE);
}
// Retrieve the function pointer and free the library again
pGetDiskFreeSpaceEx = GetProcAddress(hKernel32, "GetDiskFreeSpaceEx");
FreeLibrary(hKernel32);
// If the DLL contains this function, then it can safely be called
if (pGetDiskFreeSpaceEx != NULL)
if (GetDiskFreeSpaceEx((LPCSTR)szDest, &pqwFreeCaller, &pqwTot, &pqwFree))
{
if (nSum <= pqwFreeCaller.QuadPart)
return(TRUE);
else
return(FALSE);
}
Can anyone help with this?