65.9K
CodeProject is changing. Read more.
Home

Export C++ to VB.NET

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.25/5 (6 votes)

Feb 26, 2010

CPOL
viewsIcon

17181

If you want to export strings in C++ to VB.NET, build your function like this:BSTR __stdcall expfun(void){ char* cp_test = "Hi World!"; CString cs_test; cs_test.AppendFormat(L"%s", cp_test); return cs_test.AllocSysString();}and in VB.NET:Imports...

If you want to export strings in C++ to VB.NET, build your function like this:
BSTR __stdcall expfun(void)
{
   char* cp_test = "Hi World!";

   CString cs_test;
   cs_test.AppendFormat(L"%s", cp_test);

   return cs_test.AllocSysString();
}
and in VB.NET:
Imports System.Runtime.InteropServices
.
.
.
<DllImport("dll_path", CallingConvention:=CallingConvention.StdCall, CharSet:=CharSet.None)> _
Public Shared Function expfun() As String
End Function