VC调VC 动态库的有关问题请大侠们帮小弟我看看
VC调VC 动态库的问题请大侠们帮我看看!
有一个动态库方法char * Calc(char* chashthis)
我现在在另一个工程去用我是这样写的编译通过运行报错了,但是我在dll中还有一个简单方法就是返回 int rInt(){return 1;}没有出错.
typedef char*(_stdcall*DLLFUNC)(char*);
DLLFUNC lpFunc;
lpFunc=(DLLFUNC)::GetProcAddress(hDll, "Calc ");
我现在有一个CString 参数fileContent
char*inStr=fileContent.GetBuffer(fileContent.GetLength());
char* result=lpFunc(inStr);
我就是想得到经过转换的result
运行报错!
错误是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 convention with a function pointer declared with adifferent calling convention
------解决方案--------------------
typedef char*(_stdcall*DLLFUNC)(char*);
_stdcall*DLLFUNC把这个改成CALLBACK之类的看看
------解决方案--------------------
不同的调用方式.
------解决方案--------------------
提供方和调用方需使用相同的调用约定,要么都使用__stdcall,要么都不使用__stdcall
否则调用结束以后不平栈,程序会跑飞
------解决方案--------------------
dll里定义:
extern "C " __declspec(dllexport) void fun(.....);
引用:
typedef void (*lpfun)(....)
------解决方案--------------------
改用标准C接口调用试下看可以不。
------解决方案--------------------
因为没有传参!
有一个动态库方法char * Calc(char* chashthis)
我现在在另一个工程去用我是这样写的编译通过运行报错了,但是我在dll中还有一个简单方法就是返回 int rInt(){return 1;}没有出错.
typedef char*(_stdcall*DLLFUNC)(char*);
DLLFUNC lpFunc;
lpFunc=(DLLFUNC)::GetProcAddress(hDll, "Calc ");
我现在有一个CString 参数fileContent
char*inStr=fileContent.GetBuffer(fileContent.GetLength());
char* result=lpFunc(inStr);
我就是想得到经过转换的result
运行报错!
错误是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 convention with a function pointer declared with adifferent calling convention
------解决方案--------------------
typedef char*(_stdcall*DLLFUNC)(char*);
_stdcall*DLLFUNC把这个改成CALLBACK之类的看看
------解决方案--------------------
不同的调用方式.
------解决方案--------------------
提供方和调用方需使用相同的调用约定,要么都使用__stdcall,要么都不使用__stdcall
否则调用结束以后不平栈,程序会跑飞
------解决方案--------------------
dll里定义:
extern "C " __declspec(dllexport) void fun(.....);
引用:
typedef void (*lpfun)(....)
------解决方案--------------------
改用标准C接口调用试下看可以不。
------解决方案--------------------
因为没有传参!