when a function wants an MFC CString? TIA.
> when a function wants an MFC CString? TIA.
See: Convert from System::String* to TCHAR*/CString
http://blog.kalmbachnet.de/?postid=18
//#include <vcclr.h>
System::String *mstr = S"Hello world";
CString dest;
#ifdef _UNICODE
const __wchar_t __pin * umstring = PtrToStringChars(mstr);
#else
const char* umstring = (const char*)Marshal::StringToHGlobalAnsi
(mstr).ToPointer();
#endif
dest = umstring;
#ifndef _UNICODE
Marshal::FreeHGlobal(IntPtr((void*)umstring));
#endif

Signature
Greetings
Jochen
My blog about Win32 and .NET
http://blog.kalmbachnet.de/
James - 20 Oct 2004 20:30 GMT
Thanks for responding!! Does anyone have additional input
on how to do this from C#? I guess I'll have to write a
C++ wrapper..
>-----Original Message-----
>
[quoted text clipped - 17 lines]
> Marshal::FreeHGlobal(IntPtr((void*)umstring));
> #endif
Jochen Kalmbach - 20 Oct 2004 20:38 GMT
> Thanks for responding!! Does anyone have additional input
> on how to do this from C#? I guess I'll have to write a
> C++ wrapper..
You cannot pass a CString to an function from C#. You only can pass an
char*/wchar_t*.

Signature
Greetings
Jochen
My blog about Win32 and .NET
http://blog.kalmbachnet.de/