LoadLibrary无法正常工作

 且羞且笑且动心细 发布于 2023-02-09 19:50

我已经创建了一个*.exe*.dll我的项目.我提供了所有正确的路径和数据. Myexe.cpp:

#include "stdafx.h"
#include 

int _tmain(int argc, _TCHAR* argv[])
{
    HMODULE hInstLibrary = LoadLibrary(L("..\\Debug\\LoadDLL\\LoadDLL.dll"));// I have checked with complete path as well.
    if(hInstLibrary)
    {
        printf("Hello World");
    }
    return 0;
}

MyDLL.cpp:

#include "MyDLL.h"
#include 

    MyDLL::MyDLL(void)
    {

}


MyDLL::~MyDLL(void)
{
}

extern "C" __declspec(dllexport) void HelloWorld()
{
    printf("Hello DLL");
}

MyDLL.h:

#pragma once
class __declspec(dllexport) MyDLL
{
public:
    MyDLL(void);
    ~MyDLL(void);
};

extern "C" __declspec(dllexport) void HelloWorld();

我也试过提供complete path.但它仍然失败.这hInstLibrary是设置为0x00000.我也试过,Release mode但问题仍然存在.但是当我尝试过:

HMODULE hInstLibrary = LoadLibrary(_T("C:\\Windows\\System32\\aeinv.dll"));

它确实加载了DLL.所以,请帮助我哪里出错了.DLL正确构建,构建DLL绝对没有错误.那我为什么要面对这个问题?

是否需要进行任何设置Debug.

1 个回答
  • 您需要调用GetLastError来找出问题所在.

    编辑:

    你有0x7e,这意味着:

    ERROR_MOD_NOT_FOUND

    126(0x7E)

    指定的模块无法找到.

    你的道路是错的.你需要解决这个问题.

    2023-02-09 19:52 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有