【发布时间】:2013-12-17 12:35:32
【问题描述】:
我为我的项目创建了*.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;
}
MyDLL.cpp:
#include "MyDLL.h"
#include <stdio.h>
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是否需要设置。
【问题讨论】:
标签: c++ visual-studio-2010 dll