从C#调用Delphi DLL函数 数据类型的编组(字符数组/整数数组)
delphi函数
type
_InputPW = array[0..39] of char;
_InputPW_Len = array[0..1] of integer;
_OutPW = array[0..64] of char;
_OutPW_Len = array[0..1] of integer;
function call_encrypt_pw(Const m_InputPW : _InputPW;
Const m_InputPW_Len : _InputPW_Len;
Const m_ResultPW : _OutPW;
Const m_ResultPW_Len : _OutPW_Len
):integer;stdcall;
external 'Ext.dll' name 'call_encrypt_pw';
C#代码
[DllImport(@"Ext.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Auto)]
[return: MarshalAs(UnmanagedType.I4)]
public static extern int call_encrypt_pw(
[MarshalAs(UnmanagedType.LPStr, SizeConst = 40)] string input, [MarshalAs(UnmanagedType.LPArray, SizeConst = 2)] int[] input_len, [MarshalAs(UnmanagedType.LPStr, SizeConst = 65)] out string output, [MarshalAs(UnmanagedType.LPArray, SizeConst = 2)] out int[] output_len
);
输出/ output_len 空返回。
我认为这是编组问题。
请告诉我如何修改代码。