|
-
April 13th, 1999, 02:23 AM
#1
Using GetDiskFreeSpaceEx
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?
-
April 13th, 1999, 04:16 AM
#2
Re: Using GetDiskFreeSpaceEx
Try running DUMPBIN /EXPORTS on KERNEL32.DLL to see whether GetDiskFreeSpaceEx is present, and if so, what it is really called. On my machine (which is running NT) this shows GetDiskFreeSpaceExA and GetDiskFreeSpaceExW - the ASCII and UNICODE versions. I don't know what the W95/W98 versions are called.
-
April 13th, 1999, 05:09 PM
#3
Re: Using GetDiskFreeSpaceEx
Ahh.. Great, that's fixed it. I ran dumpbin on Kernel32.dll for NT and 95 - they both appear to have the same identifier. I can only assume that it hasn't changed in 98. Thanks for telling me about dumpbin, BTW. It seems fairly useful.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|