【发布时间】:2010-05-05 15:58:07
【问题描述】:
我需要从 C# 调用 C++ API。我已经能够调用 API,但 char[] 参数似乎没有正确编组。 这是 C++ 签名:
Create2ptModel(double modelPowers[2],
double modelDacs[2],
int pclRange[2],
double targetPowers[32],
double *dacAdjustFactor,
unsigned short powerRampFactors[32],
BOOL bPCLDacAdjusted[32],
char calibrationModel[32],
char errMsg[1024])
这就是我尝试从 C# 调用它的方式
[DllImport("AlgorithmsLib.dll", EntryPoint = "_Create2ptModel@36",
ExactSpelling = true, CallingConvention = CallingConvention.StdCall,
CharSet = CharSet.Auto)]
private static extern AlgorithmStatus Create2ptModel(
double[] modelPowers,
double[] modelDacs,
int[] pclRange,
double[] targetPowers,
ref double dacAdjustFactor,
ushort[] powerRampFactors,
bool[] bPCLDacAdjusted,
/**/char[] calibrationModel,
char[] errMsg/**/);
知道如何正确编组它吗? 提前致谢!
【问题讨论】:
-
C#中calibrationModel左边的两个星号是错字吗?
-
我认为他试图突出它们。我已经格式化了代码。
标签: c# c++ marshalling