【发布时间】:2012-10-29 22:08:03
【问题描述】:
如何将此 Clarion 过程声明转换为 C#?它是用 C 语言编写的第 3 方 DLL 的一部分,没有太多文档。我已经列出了 Clarion 中正常工作的方法的原型。在 C# 中,我不确定使用什么类型来替换 *CString。我像@DanielC 建议的那样尝试了char[],但没有奏效。我还发现 Clarion long 是 32 位的(感谢 @shf301)。
号角:
SendRequest Procedure(*CString xData,Long DataLen,Long xTimeout),Byte,Virtual
C#(我试过了,还是不行):
[DllImport("3RD_PARTY_API.dll")]
private static extern long SendRequest(ref string xData, int DataLen, int xTimeout);
当我在 C# 中调用 SendRequest 方法时,我得到了来自 VS2010 的标准 PInvokeStackImbalance was detected 错误。我认为这是参数类型的问题,而不是DllImport declaration 中的CharSet 或EntryPoint。我真的只是纠结于如何将 *CString 转换为有效的 C# 类型。
【问题讨论】: