[Mono-list] Embedded Mono using DllImport(__Internal) and returning string
efontana
eric at fontanas.net
Tue Mar 13 01:01:30 UTC 2012
Well, for Windows, I changed the code to do the following:
#ifdef WIN32
char* CSharp_Test_String()
{
string s = "hello world";
int len = s.length();
char* comem = (char*)CoTaskMemAlloc(len+1);
strcpy(comem, s.c_str());
return comem;
}
#endif
Only problem is, when I print the string out from C# it's garbage: (using
Trace.WriteLine)
so I'm guessing it's some sort of Unicode/ANSI thing. I set the
CharSet=Ansi on the DllImport.
Any ideas?
--
View this message in context: http://mono.1490590.n4.nabble.com/Embedded-Mono-using-DllImport-Internal-and-returning-string-tp4467177p4467877.html
Sent from the Mono - General mailing list archive at Nabble.com.
More information about the Mono-list
mailing list