C++ string marshalling

neural20

New member
Joined
Dec 18, 2006
Messages
1
Programming Experience
Beginner
Hello,

I am a newbie to .Net programming, but here it goes..
There is a native C++ .DLL which i developed as a wrapper around a VB .Net assembly.
In the C++ DLL there is an exported function:

__declspec(dllexport) int __stdcall MyFunc(char *str1,char *str2)
which calls a function inside the VB assembly with the following signature:

function MyVBFunc( ByVal s1 as String, ByVal s2 as String) as String

1) How do I call MyVBFunc from native C++ so that str1 and str2 are converted to CLR String objects ?
2) How can the returned String from MyVBFunc be marshalled back into a char * visible to the MyFunc caller?

I mention that the C++ DLL is and must contain 100% non-managed code, the VB assembly contains a COM class and the DLL calls it by instantiating a COM object with CoCreateInstance.
Thank you so much :)
 
Last edited:
To get answers to C++ programming you should seek advice at a C++ forum. Although there may be VB people here that also have C++ knowledge this site is dedicated to VB.Net only. There may be times discussed here how to call unmanaged libraries, but we don't program in C++ here. You're right the .Net assembly must export as COM to be used from unmanaged platform.
 
Back
Top