求助:我的 dll 中的数组调用总是出错,请帮我看看啊,谢谢!
请教:
// iTween.cpp : 定义 DLL 应用程序的导出函数。
#ifdef ITWEEN_EXPORTS
#define DLL_API __declspec(dllexport)
#else
#define DLL_API __declspec(dllimport)
#endif
int groupID = 0xC154;
char dogOnlyId[30] = "314A990D1A6E4D0F";
extern "C" DLL_API int ReadGroupID()
{
return groupID;
}
extern "C" DLL_API void ReadDogOnlyId(char *getDogOnlyId)
{
getDogOnlyId = dogOnlyId;
}
编译为 iTween.dll
// Test1.cpp : 定义 DLL 应用程序的导出函数。
#ifdef TEST1_EXPORTS
#define DLL_API __declspec(dllexport)
#else
#define DLL_API __declspec(dllimport)
#endif
int groupID = 0xC153; //分组号
char dogOnlyId[64] = "314A990D1A60F";
extern "C" DLL_API int readNumber()
{
HINSTANCE hDllInst = LoadLibrary("iTween.dll");
typedef int (WINAPI *FunReadGroupID)();
typedef void (WINAPI *FunReadDogOnlyId)(char *);
FunReadGroupID MyReadGroupID = NULL; //函数别名
FunReadDogOnlyId MyReadDogOnlyId = NULL;
MyReadGroupID = (FunReadGroupID)GetProcAddress (hDllInst, "ReadGroupID");
MyReadDogOnlyId = (FunReadDogOnlyId)GetProcAddress (hDllInst, "ReadDogOnlyId");
if(MyReadGroupID)
{
groupID = MyReadGroupID();
}
if(MyReadDogOnlyId)
{
MyReadDogOnlyId(dogOnlyId);
}
FreeLibrary(hDllInst);
}
编译为 Test1.dll
现在情况是,我在别的程序调用 Test1.dll 的 readNumber()
当执行 MyReadDogOnlyId(dogOnlyId);
就出现错误。
Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call.
This is usually of calling a function declared with one calling convention with a function
pointer declared with a different calling convention
我哪里错了啊?
谢谢!