C# 调用delphi dll问题 pchar 返回乱码
4.读取返回结果dll库functionComPortRead(Port:Integer;varSize:Word;Timeout:Cardinal):PChar;std...
4.读取返回结果 dll库
function ComPortRead(Port: Integer; var Size: Word; Timeout: Cardinal): PChar; stdcall; external 'ComPortDll.dll';
//读取返回值C#
[DllImport("ComPortDll.dll", EntryPoint = "ComPortRead", CharSet = System.Runtime.InteropServices.CharSet.Auto, SetLastError = false)]//, CallingConvention = CallingConvention.Cdecl)]
public static extern string ComPortRead(int port, ref short Size, uint Timeout);
得到值为一个字符,应该是一个长字符串 展开
function ComPortRead(Port: Integer; var Size: Word; Timeout: Cardinal): PChar; stdcall; external 'ComPortDll.dll';
//读取返回值C#
[DllImport("ComPortDll.dll", EntryPoint = "ComPortRead", CharSet = System.Runtime.InteropServices.CharSet.Auto, SetLastError = false)]//, CallingConvention = CallingConvention.Cdecl)]
public static extern string ComPortRead(int port, ref short Size, uint Timeout);
得到值为一个字符,应该是一个长字符串 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询