我不知道我的题目是否恰当.具体问题如下.已有(VC++)Add.dll
Add.h
__declspec(dllexport) int add(int x,int y)aDD.cpp
__declspec(dllexport) int add(int x,int y)
{
return x+y;
}然后在一个Com工程中调用 Add.dll 代码如下HINSTANCE hh=NULL;
hh=AfxLoadLibrary("Add.dll");
typeof int(*ADD)(int,int);
ADD add;
add=(ADD)GetProcAddress(hh,"add");
int z;
z=add(2,3);
当执行到 最后一句时就报错.File:i386\chkesp.c
line:42
the value of ESP was not properly saved across a function call,This is usually a result of calling a function declared with one calling coneention with a function pointer declared with a different calling convention.
Add.h
__declspec(dllexport) int add(int x,int y)aDD.cpp
__declspec(dllexport) int add(int x,int y)
{
return x+y;
}然后在一个Com工程中调用 Add.dll 代码如下HINSTANCE hh=NULL;
hh=AfxLoadLibrary("Add.dll");
typeof int(*ADD)(int,int);
ADD add;
add=(ADD)GetProcAddress(hh,"add");
int z;
z=add(2,3);
当执行到 最后一句时就报错.File:i386\chkesp.c
line:42
the value of ESP was not properly saved across a function call,This is usually a result of calling a function declared with one calling coneention with a function pointer declared with a different calling convention.
解决方案 »
- STL::map的第三个参数Traits,用于指定Key的排序函数,谁给个例子看一下?
- 大家帮帮,mfc按键怎样加载位图
- 感觉这里人最多,问个问题,关于installshield12
- 删除mfc 文档类后 出现E:\c++\Mine\Mine.cpp(70) : error C2653: 'CMineDoc' : is not a class or namespace name
- 100分求助。跨进程消息,窗体不被点击激活就无法处理?
- VC 和 (VB,Delphi)的设计区别
- 问一个关于菜单项ID的问题。
- 请教:图片缩小的问题
- 请教:现在共享软件做什么比较好啊
- 一个看似简单的问题,我却不会,请大家帮忙!
- 求《深入解析ATL》源代码!
- 请教 单文档和多文档的使用 很简单
我按照你的提示将.Add.dll中的函数声明前加上了 __stdCall 重新编译后问题解决了.但新的问题出现了.
如果函数的返回类型是 char* 时不能在前面加上 __str
我想知道char* 类型在标准调用时应该用什么类型代替.
是用typedef 定义一个吗?我试试.