我已经创建了一个*.exe
与*.dll
我的项目.我提供了所有正确的路径和数据.
Myexe.cpp
:
#include "stdafx.h" #includeint _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" #includeMyDLL::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
.
您需要调用GetLastError来找出问题所在.
编辑:
你有0x7e,这意味着:
ERROR_MOD_NOT_FOUND
126(0x7E)
指定的模块无法找到.
你的道路是错的.你需要解决这个问题.