G
Guest
HI
In keeping with my policy of always using _TCHAR*s when possible, I am
trying to convert a System::String* to a _TCHAR*.
When I use this (my eventual aim is to get it into a pre-allocated,
unmanaged, _TCHAR* called 'error'):
const _TCHAR* umstring = (const
_TCHAR*)Marshal::StringToHGlobalAuto(merror).ToPointer();
_tcscpy(error, umstring);
Marshal::FreeHGlobal(IntPtr((void*)umstring));
then 'error' only receives the first character of the System::String*.
But when I do
const char* umstring = (const
char*)Marshal::StringToHGlobalAnsi(merror).ToPointer();
_tcscpy(error, umstring);
Marshal::FreeHGlobal(IntPtr((void*)umstring));
it gets it all OK.
Why can't I do it with _TCHAR*s?
In keeping with my policy of always using _TCHAR*s when possible, I am
trying to convert a System::String* to a _TCHAR*.
When I use this (my eventual aim is to get it into a pre-allocated,
unmanaged, _TCHAR* called 'error'):
const _TCHAR* umstring = (const
_TCHAR*)Marshal::StringToHGlobalAuto(merror).ToPointer();
_tcscpy(error, umstring);
Marshal::FreeHGlobal(IntPtr((void*)umstring));
then 'error' only receives the first character of the System::String*.
But when I do
const char* umstring = (const
char*)Marshal::StringToHGlobalAnsi(merror).ToPointer();
_tcscpy(error, umstring);
Marshal::FreeHGlobal(IntPtr((void*)umstring));
it gets it all OK.
Why can't I do it with _TCHAR*s?