Imisspassword 2016-09-07 03:06 采纳率: 0%
浏览 944

VC和BCB编写DLL。 DWORD WINAPI 怪问题

函数原型是:DWORD (WINAPI* m_pfnGetInfo)(int nInfo, void* pBuf);
2个动态库,原来用BCB写的,没问题,
C++ BULIDER中这样:
extern "C" __declspec(dllexport) DWORD WINAPI GetInfo(int nInfo,void * pBuf)
VC2008,同样写
extern "C" __declspec(dllexport) DWORD WINAPI GetInfo(int nInfo,void * pBuf)
结果是GetProcAddress返回空,
改成这样:
extern "C" __declspec(dllexport) DWORD GetInfo(int nInfo,void * pBuf)
GetProcAddress返回正常,但调用时出错,信息为:Run-Time Check Failure #0 - 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 a different calling convention.
百思不得其姐!

  • 写回答

3条回答 默认 最新

  • wlj1234 2016-09-07 04:11
    关注

    没用过BCB,只知道这两个编译器生成的函数参数出入栈顺序不一致。
    所以WINAPI这个宏要重新定义一下,VC中WINAPI默认__stdcall

    出错原因是调用者实际调用是下面的函数
    extern "C" __declspec(dllimport) DWORD GetInfo(void * pBuf,int nInfo)

    GetProcAddress返回空,应该也是这个问题

    评论

报告相同问题?