Returning a string* as a result in WndProc

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a C++ dialog that is sending a message to my C# window and I need to
pass a string* back in the result of the message. On the C++ side this result
is cast as a CString*. How do I create this string on the C# side and convert
it to an IntPtr? My first guess is to allocate memory and copy the string to
it and then let the C++ app clean it up.

Thanks
Kurt
 
How do I create this string on the C# side and convert
it to an IntPtr? My first guess is to allocate memory and copy the string to
it and then let the C++ app clean it up.

Sure that will work, and you can do it with one of the
Marshal.StringTo* methods.




Mattias
 
Ok I'm using StringToHGlobalAnsi and the string I get on the other side is
blank.

Here is my code on the C++ side.

CString p((char*)lResult);
 
Ok I'm using StringToHGlobalAnsi and the string I get on the other side is
blank.

Here is my code on the C++ side.

CString p((char*)lResult);


You're gonna have to show more of your code.



Mattias
 
Back
Top