Ras*_*yak 1 c++ dll visual-studio-2010
我已经创建了一个*.exe与*.dll我的项目.我提供了所有正确的路径和数据.
Myexe.cpp:
#include "stdafx.h"
#include <Windows.h>
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;
}
Run Code Online (Sandbox Code Playgroud)
MyDLL.cpp:
#include "MyDLL.h"
#include <stdio.h>
MyDLL::MyDLL(void)
{
}
MyDLL::~MyDLL(void)
{
}
extern "C" __declspec(dllexport) void HelloWorld()
{
printf("Hello DLL");
}
Run Code Online (Sandbox Code Playgroud)
MyDLL.h:
#pragma once
class __declspec(dllexport) MyDLL
{
public:
MyDLL(void);
~MyDLL(void);
};
extern "C" __declspec(dllexport) void HelloWorld();
Run Code Online (Sandbox Code Playgroud)
我也试过提供complete path.但它仍然失败.这hInstLibrary是设置为0x00000.我也试过,Release mode但问题仍然存在.但是当我尝试过:
HMODULE hInstLibrary = LoadLibrary(_T("C:\\Windows\\System32\\aeinv.dll"));
Run Code Online (Sandbox Code Playgroud)
它确实加载了DLL.所以,请帮助我哪里出错了.DLL正确构建,构建DLL绝对没有错误.那我为什么要面对这个问题?
是否需要进行任何设置Debug.
您需要调用GetLastError来找出问题所在.
编辑:
你有0x7e,这意味着:
ERROR_MOD_NOT_FOUND
126(0x7E)
指定的模块无法找到.
你的道路是错的.你需要解决这个问题.