Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

LoadLibrary("KERNEL32.DLL")

658 views
Skip to first unread message

Mark Taguchi

unread,
Jan 23, 1998, 3:00:00 AM1/23/98
to

Please help!

In the following code, I get zero from GetProcAddress(...); with
GetLastError()
returning 126(=The specified module could not be found)
Any help would be appreciated...

HINSTANCE handleK32 = LoadLibrary("KERNEL32.DLL");
if (handleK32 != NULL)
{
LPFNDLLFUNC1 pfnDllFunc =
(LPFNDLLFUNC1)GetProcAddress(handleK32, "GetDiskFreeSpaceEx");
:
DWORD err = GetLastError();
:
Mark T...


Steve Magara

unread,
Jan 23, 1998, 3:00:00 AM1/23/98
to

> HINSTANCE handleK32 = LoadLibrary("KERNEL32.DLL");
> if (handleK32 != NULL)
> {
> LPFNDLLFUNC1 pfnDllFunc =
> (LPFNDLLFUNC1)GetProcAddress(handleK32, "GetDiskFreeSpaceEx");

The kernel is already loaded when your machine boots up so there is no need
to force this dll to load.

Anyway, you don't have to load the library to call this function, just
include winbase.h and call GetDiskFreeSpaceEx() as described in the help.
In the IDE, put your cursor on GetDiskFreeSpaceEx and press F1 to view the
help on its usage.

Hope this helps,
Steve M

Greg Gagnaux

unread,
Jan 23, 1998, 3:00:00 AM1/23/98
to

Mark,

If your running under WinNT or Win95 OSR2 do these steps

HINSTANCE hDLL = LoadLibrary("kernel32.dll");
if (hDLL)
{
#ifdef UNICODE
LPFNDLLFUNC1 procGetDiskFreeSpaceEx =
(LPFNDLLFUNC1)GetProcAddress(hDLL, "GetDiskFreeSpaceExW");
#else
LPFNDLLFUNC1 procGetDiskFreeSpaceEx =
(LPFNDLLFUNC1)GetProcAddress(hDLL, "GetDiskFreeSpaceExA");
#endif
if (procGetDiskFreeSpaceEx)
{
// Do something
}
FreeLibrary(hDLL);
}


Greg Gagnaux
Windows Software Developer
gagnaux@~ibm.net
remove ~ to email

Mark Taguchi

unread,
Jan 24, 1998, 3:00:00 AM1/24/98
to

This has been answered. Thank you.

> :


0 new messages