4
我试图通过从C#中的字符串德尔福创建的DLL。 德尔福DLL期待PChar。传递字符串作为PChar类型从CSHARP德尔福DLL
这里是德尔福出口
procedure DLL_Message(Location:PChar;AIntValue :integer);stdcall;
external 'DLLTest.dll';
C#进口(最后一个我想,有串字符*参考串...)
[DllImport(
"DLLTest.dll",
CallingConvention = CallingConvention.StdCall,
CharSet = CharSet.Ansi,
EntryPoint = "DLL_Message"
)]
public static extern void DLL_Message(IntPtr Location, int AIntValue);
我收到访问冲突在任何访问值办法。
是否有任何解决方案,通过在C#中的字符串值作为PChar类型?
的MarshalAs。这是默认编组。对于DllImport属性的参数同样如此。只需要文件名。 – 2012-02-15 00:10:48
你确定吗?不是默认的UnmanagedType.LPWStr(UTF-16)? – 2012-02-15 10:02:10
显然,这是BSTR:http://msdn.microsoft.com/en-us/library/s9ts558h.aspx – 2012-02-15 10:08:02