0

How do I properly return a char * from an Unmanaged DLL to VB .net and use it as a string in VB? From a similar post for C# and C++ it appears that the c# syntax to do such a thing is

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

Does VB .net have a corresponding syntax?

Community
  • 1
  • 1
chtenb
  • 14,924
  • 14
  • 78
  • 116

1 Answers1

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