我正在尝试将一个字符串从C#传递到Delphi构建的DLL。Delphi DLL期望PChar。
这是Delphi导出:
procedure DLL_Message(Location:PChar;AIntValue :integer);stdcall;
external 'DLLTest.dll';
C#导入(上一次我尝试时,有字符串、char*和ref string...)
[DllImport(
"DLLTest.dll",
CallingConvention = CallingConvention.StdCall,
CharSet = CharSet.Ansi,
EntryPoint = "DLL_Message"
)]
public static extern void DLL_Message(IntPtr Location, int AIntValue);
我以任何方式访问值时都会出现访问冲突。
在C#中,有没有将字符串值作为PChar传递的解决方案?