*******************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;
}
为了调用已创建的具有向我的邮件服务器发送邮件功能的Dll1.dll,需要执行上述代码。代码运行并退出,但没有发送任何邮件。
我还将Dll1.dll放置在与UseDll1相同的文件夹中。
编辑: 我将Dll1.dll添加到了system32文件夹中。