C#????C/C++DLL??????????????
?????ccqin ???????[ 2016/7/15 10:36:29 ] ??????????????????? .NET
????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??????????????????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11