C++
一种通用的高级编程语言,作为 C 编程语言的扩展而创建,除了用于低级别内存操作的功能外,还具有面向对象、泛型和功能性等特点。
67 个问题
我在我的 C# 程序中调用了 CPPDLL。以下是我的 C# 代码片段:
**public struct ImageData
{
public int imageSize;
public byte[] image;
}
public struct CppImportInfo
{
public byte[] name { get; set; }
public byte[] id;
public int group;
public byte[] company;
public byte[] e_mail;
public byte[] title;
public byte[] note;
public ImageData imageData;
};
class CDllWrapper
{
#region Dll interface
public CDllWrapper() { }
[DllImport("FRV_Dll", //name of the dll
EntryPoint = "Face_Register", //name of function in dll
ExactSpelling = true,
CharSet = CharSet.Ansi,
CallingConvention = CallingConvention.Cdecl)]
......
}**
以下是我在 CPP DLL 上的代码片段:
**struct ImageData
{
int imageSize;
unsigned char* image;
};
struct ImportInfo
{
char* name;
.......
char* note;
struct ImageData imageData;
};
//ensure naked export
extern "C"
{
......
CPLUSPLUS_API int Face_Register(struct ImportInfo *imageData, int* retCode, char** retMessage);
...
}**
当我检查imageInfo->imageData.image时,我发现它是错误的。怎么会这样?
Note:此问题总结整理于:Data structure of parameters from C# calling CPP DLL