I'm not sure what other groups this should go to, but I'm trying to
write a Win32 DLL that I can call from my vb.net app. I'm having a
real tough time, as this is printing a different char set than what I
expect. I'm not sure if I'm doing something wrong or its not setup
right, but it looks like Chinese characters coming back. Here is all
the code:
Win32 exported function:
int CDllTest::TestFunc3(TCHAR* lStr, int* lLen)
{
TCHAR* x=NULL;
x = (char *)calloc(10000,sizeof(char));
strcpy(x, "abcabcd");
strcpy(lStr, x);
*lLen = strlen(lStr);
return 0;
}
VB.net method:
Declare Auto Function TestFunc3 Lib "TestDLL" (ByVal msg As
StringBuilder, ByRef msgLength As IntPtr) As Integer
Dim s1 As StringBuilder
Dim i2 As IntPtr
s1 = New StringBuilder(1000)
i1 = TestFunc3(s1, i2)
Trace.WriteLine(s1.ToString & " " & i2.ToInt32)
When trace writes s1.tostring, it seems like chinese characters,
however the length is correct, so its got something to do with the way
its marshalled I guess.
Any help would be great !!!!!
Mark