调用DLL,被卡住了,求帮忙

yeyanyu 2009-12-16 04:48:23
自己写了C++程序 调用自己写的C++的dll 老是调用不起dll里面的方法。请大侠看看
调用dll程序:
#include "stdafx.h"
#include<iostream>
#include "windows.h"
typedef void(__stdcall *Print_)();
int main(){

HINSTANCE hDll; //DLL句柄
Print_ print_; //函数指针
hDll = LoadLibrary(L"C:/native.dll");

if (hDll != NULL)
{
printf("11111") ;
print_ = (Print_)GetProcAddress(hDll,"FunctionA");
if(print_!=NULL)
{
printf("22222") ;
print_();
}
FreeLibrary(hDll);
}
printf("33333") ;
return 0;
}
dll程序:
#include "stdafx.h"
#include<iostream>
using namespace std ;
void FunctionA()
{
printf("gogogogogog");
}
程序运行结果1111133333
2222 和gogogo都没显示
说明函数没掉出来 到底哪里有问题呢?
...全文
193 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
zweifly 2009-12-17
  • 打赏
  • 举报
回复
错了
extern "C" __declspec(dllexport) void FunctionA()


zweifly 2009-12-17
  • 打赏
  • 举报
回复
__declspec(dllimport) extern "C" void FunctionA()
yeyanyu 2009-12-17
  • 打赏
  • 举报
回复
谢谢 对了
yeyanyu 2009-12-16
  • 打赏
  • 举报
回复
#include "stdafx.h"
#include <iostream>
using namespace std ;
extern "C" void FunctionA()
{
printf("gogogogogog");
}
改成这样也不行呀

问题就是怎么导出来噢?
sandyandy 2009-12-16
  • 打赏
  • 举报
回复
dll中的函数没有导出
  • 打赏
  • 举报
回复
改名了 前面加上extern "C"
extern "C" void FunctionA()

15,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 进程/线程/DLL
社区管理员
  • 进程/线程/DLL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧