Loadlibrary无法加载dll [英] Loadlibrary fails to load dll

查看:166
本文介绍了Loadlibrary无法加载dll的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

    *******************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发送邮件到我自己的邮件服务器。上面的代码运行并退出,并且没有邮件发送。

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.

然后我还将Dll1.dll与UseDll1放在同一文件夹中。

And i also placed the Dll1.dll in the same folder as UseDll1.

编辑:
我将Dll1.dll添加到了system32文件夹中。

I added the Dll1.dll into the system32 folder.

推荐答案

是否已验证 DLL1具有所有外部依赖项。 dll?

Have you verify that you have all external dependencies for "DLL1.dll" ?

即使没有任何间接链接库,LoadLibrary也将失败。

LoadLibrary will fail even if any of the indirect linked-library is not available.

这篇关于Loadlibrary无法加载dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆