win32 DLL库加载失败之.def文件没设置输入到DLL中

环境:VS2010

设置:.dll与.exe在同一个目录下

问题:LoadLibrary(_T("***.dll"));返回空句柄

dll调用代码:

#include "stdafx.h"
#include "math.h"
typedef IMath*(*INSTANCE)( );
IMath* GetMath(){
HINSTANCE hDll=LoadLibrary(_T("DLLInterface.dll"));
INSTANCE instance=(INSTANCE)GetProcAddress(hDll,"CreateInstance");
DWORD dwErr=GetLastError();
Sleep(10000);
IMath* math=instance();
// FreeLibrary(hDll);
return math;
}
int _tmain(int argc, _TCHAR* argv[])
{
IMath* math=GetMath();
int sum=math->Add(12,34);
printf("%d\n",sum);
return 0;
}

问题原因:

要将项目属性->配置属性->连接器->输入->模块定义文件-----设置为./DLLInterface.def

Note:

项目属性->配置属性->常规->中间目录-------存放pdb调试文件

项目属性->配置属性->连接器->常规->输出目录------存放可执行文件

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值