现在有一CBC做的DLL,我在程序中调用的时候出错了,请帮我看看HMODULY hModuly=LoadLibrary("dllname.dll");
FARPROC proc=GetProcAddress(hModule,"Proc1");
if(proc==NULL) return 0;
typedef HANDLE (* FUNC)();
FUNC proc1=(FUNC)proc;
HANDLE re=proc1();
//上面代码没问题
FARPROC proc2=GetProcAddress(hModule,"Proc2");
if(proc2==NULL) return 0;
typedef int (* FUNC2)(HANDLE);
FUNC2 proc3=(FUNC2)proc2;
int re2=proc3(hWnd);
//调用proc3的时候出错!
编译没错,运行时出错!error code:
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 copnvention with a function pointer declared with a
different calling convention.
FARPROC proc=GetProcAddress(hModule,"Proc1");
if(proc==NULL) return 0;
typedef HANDLE (* FUNC)();
FUNC proc1=(FUNC)proc;
HANDLE re=proc1();
//上面代码没问题
FARPROC proc2=GetProcAddress(hModule,"Proc2");
if(proc2==NULL) return 0;
typedef int (* FUNC2)(HANDLE);
FUNC2 proc3=(FUNC2)proc2;
int re2=proc3(hWnd);
//调用proc3的时候出错!
编译没错,运行时出错!error code:
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 copnvention with a function pointer declared with a
different calling convention.
解决方案 »
- 打印预览页面问题,附代码
- 如何让托盘(通知区)图标闪动?
- OnEraseBkgnd()函数的功能是什么?(高手请进)
- 为什么这段程序为什么在win2k xp操作系统下运行都正常而在98下会出问题呢??
- 冬天来了,难道真的要冻饿而死?不让过年了?(关于可用分)
- 请问各位高手,如何关闭一个没有主窗口的程序!(在线等待)
- 如何获取当前工作的网卡?
- 断言失败,如何查出问题在那
- 如何利用ATL去实现可变参数个数的COM接口方法?
- UDP和TCP协议
- 类似于VB或Delphi控件的表格属性窗是怎么实现的,VC的控件属性窗又是怎么做出来的?
- 我用CreateFile打开了并口,用的是读写两种访问方式,再用ReadFile和WriteFile读写数据时,程序就会进入没反应状态,要强行关闭,估计是
DWORD (WINAPI *fn)(DWORD,DWORD);//你的函数原型
if(hInst)
{
fn=(DWORD(WINAPI(DWORD,DWORD))::GetProcAddress((HMODULE)hInst,("Proc1"));
if(fn)
(*fn)(param1,param2);
::FreeLibrary (hInst);
return true;
}
声明要改为 int (* __stdcall FUNC2)(HANDLE);
如果还不是,把连接选项去掉试试/GZ
改成
int re2=(*proc3)(hWnd);