如何正确地将char *从用C编写的非托管DLL返回到VB .net?

时间:2016-08-29 10:08:18

标签: .net c vb.net interop unmanaged

如何正确地将char *从非托管DLL返回到VB .net并在VB中将其用作字符串? 从a similar post for C# and C++看来,执行此类操作的c#语法是

[DllImport("api.dll")]
[return : MarshalAs(UnmanagedType.LPStr)]
internal static extern string errMessage(int err);
...
string message = errMessage(err);

VB .net是否有相应的语法?

1 个答案:

答案 0 :(得分:0)

<DllImport("Project1.dll", SetLastError:=True, CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Cdecl)>
Function agmemwrite(graph As IntPtr) As <MarshalAs(UnmanagedType.LPStr)> String
End Function