Article ID: 151596
Article Last Modified on 12/3/2003
#include "windows.h"
#include "stdio.h"
//
// Functions
//
typedef int (*fnInternal)(void);
void main(int iArgs, char *strArgs[], char *strEnvs[]);
void vUsage(void);
//
// Main function
//
void main(int iArgs, char *strArgs[], char *strEnvs[])
{
HINSTANCE hLib = NULL;
fnInternal fCall = NULL;
char strMsg[1025] = "";
if(iArgs == 3)
{
printf("\nAttempting to load %s - %s\n",
strArgs[1], strArgs[2]);
if( (hLib = LoadLibrary(strArgs[1])) != NULL)
{
fCall = (fnInternal)GetProcAddress(hLib, strArgs[2]);
if(fCall)
{
printf("%s found and loaded successfully.\n",
strArgs[2]);
}
else
printf("%s not found in %s.\n", strArgs[2],
strArgs[1]);
FreeLibrary(hLib);
}
else
{
::FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
GetLastError(),
GetSystemDefaultLangID(),
strMsg,
sizeof(strMsg) -1,
NULL);
printf("Error %ld %s\n", GetLastError(), strMsg);
}
}
else
vUsage();
printf("\n");
}
//
// vUsage
//
void vUsage(void)
{
printf("\n"
"Usage: Loadlib.exe libname function\n"
"\n"
"Where: libname = 8.3 name of library\n"
" function = name of function in the library\n"
"\n"
"Example: loadlib xplog70.dll xp_msver\n");
}
Additional query words: tshoot
Keywords: kbinfo kbprogramming KB151596