D
Dave
Hi everyone. Okay, I'm trying to dynamically link some dlls and I'm
having some problems. I originally had a project that seems to work,
but for the life of me I can't repeat the results.
I used app wizard to create a simple Win32 Dynamic Linked library. the
code is as follows:
#include "stdafx.h"
#include "stdio.h"
int i = 0;
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
void _stdcall InitDll(){
i = 1;
}
I build that and get 'TestDll.dll'
The program I use to open this dll looks like this:
#include "stdafx.h"
#include <windows.h>
typedef void(__stdcall *InitDllOperation)();
int main(int argc, char* argv[])
{
InitDllOperation initDll;
HINSTANCE dllLib = LoadLibrary("TestDll.dll");
if( dllLib == NULL )
{
printf( "Unable to load library\n");
return 1;
}
else
{
printf( "loaded library successfully\n");
}
initDll =
(InitDllOperation)GetProcAddress((HINSTANCE)dllLib,"InitDll");
if( initDll == NULL )
{
printf( "initDll failed to load\n");
return 1;
}
else
{
printf( "init Success\n");
}
return 0;
}
Every time the library loads successfully, but the 'initDll' object is
ALWAYS Null. The return from GetProcAddress seems to always come up
null. Any suggestions?
Thanks
having some problems. I originally had a project that seems to work,
but for the life of me I can't repeat the results.
I used app wizard to create a simple Win32 Dynamic Linked library. the
code is as follows:
#include "stdafx.h"
#include "stdio.h"
int i = 0;
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
void _stdcall InitDll(){
i = 1;
}
I build that and get 'TestDll.dll'
The program I use to open this dll looks like this:
#include "stdafx.h"
#include <windows.h>
typedef void(__stdcall *InitDllOperation)();
int main(int argc, char* argv[])
{
InitDllOperation initDll;
HINSTANCE dllLib = LoadLibrary("TestDll.dll");
if( dllLib == NULL )
{
printf( "Unable to load library\n");
return 1;
}
else
{
printf( "loaded library successfully\n");
}
initDll =
(InitDllOperation)GetProcAddress((HINSTANCE)dllLib,"InitDll");
if( initDll == NULL )
{
printf( "initDll failed to load\n");
return 1;
}
else
{
printf( "init Success\n");
}
return 0;
}
Every time the library loads successfully, but the 'initDll' object is
ALWAYS Null. The return from GetProcAddress seems to always come up
null. Any suggestions?
Thanks