*******************UseDll1.cpp*********************
#include <windows.h>
typedef int (*function1_ptr) ();
function1_ptr function1=NULL;
int APIENTRY WinMain(HINSTANCE, HINSTANCE, LPSTR, int) {
HMODULE myDll = LoadLibrary("Dll1.dll");
if(myDll!=NULL) {
function1 = (function1_ptr) GetProcAddress(myDll,"function1");
if(function1!=NULL)
function1();
else
exit(4);
FreeLibrary(myDll);
}
else
exit(6);
return 0;
}
This is done in order to call Dll1.dll which was created with the functionality to send mail to my own mail server. The above code runs and exits,and no mail is sent.
And i also placed the Dll1.dll in the same folder as UseDll1.
EDIT: I added the Dll1.dll into the system32 folder.
Have you verify that you have all external dependencies for "DLL1.dll" ?
LoadLibrary will fail even if any of the indirect linked-library is not available.
In my dll calling experience, I had same problem. I did everything for giving path rightly but my library can not be loaded. Firstly I thought my dll had error, but nothing solved my problem at start. I advice doing below step for friends who think their project written rightly but still having same problem:
After building project with right configuration, it is working now.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With