求助:我的 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
我哪里错了啊?
谢谢!
// 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
我哪里错了啊?
谢谢!
...全文
相关推荐
c#调用c++DLL,dll有二维数组
c#调用c++DLL,DLL里是二维数组 ,c#里如何调用二维数组
java用JNA调用dll实例,包含各种参数调用
实例中演示了各种参数形式的DLL函数调用,如:基本数据类型、基本数据类型的指针和引用、结构体、结构体的指针和引用、函数指针和回调函数、字符串指针、输入数组、输出数组等,非常实用。
基于C#调用c++Dll结构体数组指针的问题详解
下面小编就为大家分享一篇基于C#调用c++Dll结构体数组指针的问题详解,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
C#动态调用Dll中的方法
根据字符串调用同名函数,反射
C#调用C++ Dll关于结构体数组引用的传递及解析使用的展示代码
资源代码演示的是c#代码调用c++ DLL 的方式。该演示为原创,绝非搬砖。解决了c# 调用 C++ Dll获取相关信息之如何传递结构体数组引用以及如何处理获取到的结构体数组数据的问题。


