Code
typedef unsigned short prWChar;
typedef unsigned long prUInt32;
typedef prUInt32 prResponse;
#define prCAPI prResponse __declspec(dllexport) prSTDCALL //这个不明白是什么意思
#define prANY 1
typedef struct{
prWChar ModuleName[512]; /* Module name (512 characters) */
prWChar Version[32]; /* Version (32 characters) */
}prVerInfo;
typedef struct{
prUInt32 Entry; /* Number of modules included
in this structure */
prVerInfo VerInfo[prANY]; /* Array of file version number
information of PS-ReC SDK modules */
}prDllsVerInfo;
//函数
prCAPI PR_GetDllsVersion(
prUInt32* pBufferSize,
prDllsVerInfo* pDllVersion
);
pBufferSize为In/Out,pDllVersion为Out
转化为C#的代码为
定义结构
Code
using System.Runtime.InteropServices;
public struct prVerInfo{
public ushort[] ModuleName; /* Module name (512 characters) */
public ushort[] Version; //32 characters
}
public struct prDllsVerInfo {
public uint Entry;
public prVerInfo[] VerInfo;
};
定义函数
Code
[DllImport("..\\..\\Lib\\PRSDK.dll", CharSet = CharSet.Ansi)]
public static extern uint PR_GetDllsVersion(
ref uint pBufferSize,
out prType.prDllsVerInfo pDllVersion
);
调用
Code
prDllsVerInfo prDllVerInfo = new prDllsVerInfo();
prDllVerInfo.VerInfo = new prType.prVerInfo[1];
prDllVerInfo.VerInfo[0].ModuleName = new ushort[512];
prDllVerInfo.VerInfo[0].Version = new ushort[32];
err = CanonCamera.PR_GetDllsVersion(ref buffersize, out prDllVerInfo);
报错,请问该如何在C#中调用C++的这种指针结构
System.ExecutionEngineException was unhandled
Message="引发类型为“System.ExecutionEngineException”的异常。"
搞了好一会,都不得而解,希望大家帮帮我,帮我看看哪里出错了。