????C#???????P/Invoke????C/C++д??DLL????????DLL??????????????鷳???????????????????????????
??????DLL????????????????????????????????C#???????????????
????C/C++???????????char* ??wchar_t*???????char*???????ANSCII??????? wchar_t*???Unicode???????Unicode???????C/C++???????????????????ANSII???????????????????????????????????)?? ???C++?????????char*???????????C#??????byte[] ??????????????壬 ???C#??char ??????????????
????????C++?н?????
????void testStr(char *buf?? int size);
??????C#???????μ????????
????[Dllimport("yourdll.dll")]
????extern int testStr(IntPtr buf?? int size);
?????????μ???
????byte[] buf = new byte[LEN];
????int len = testStr(Marshal.UnsafeAddrOfPinnedArrayElement(buf?? 0)?? buf.length);
????byte[] cvtBuf = new byte[LEN];
????//??????????????? ??????????????ANSII????unicode??????????char* ->unicode
????//?????_TCHAR??wchar_t??????????????????char[]??????崫??
????cvtBuf = Encoding.Convert(Encoding.Default?? Encoding.Unicode?? buf ?? 0?? len-1);
????string recvStr = Marshal.PtrToStringAuto(Marshal.UnsafeAddrOfPinnedArrayElement(cvtBuf ?? 0));
???????????????????C#??????????????
????C++???и???????????????????WideCharToMultiByte??MultiByteToWideChar????????MSDN???????.
??????????C/C++????????JNI??Java??????????????????????????