0
点赞
收藏
分享

微信扫一扫

c#传字符串数组给c++

seuleyang 2022-04-25 阅读 57
c++c#

如果有中文的话,在 C# 端使用 CharSet = CharSet.Unicode
C#端:

[DllImport("capturePicture.dll",CharSet = CharSet.Unicode, EntryPoint = "ReceiveStrArr")]
public extern static int SendStrArr(string[] sendS, int arraySize);

C++端:

extern "C" _declspec(dllexport) int _stdcall ReceiveStrArr(wchar_t** receiveS, int arraySize)
{
 
    vector<wstring> receiveStrs;
 
    for (int i = 0; i < arraySize; i++)
    {
        wstring wstr = *(receiveS + i);
        receiveStrs.push_back(wstr);
    }
 
    return 0;
}

如果传递的字符串中没有中文的话,可以使用 CharSet = CharSet.Ansi,在C++端使用 char** 接收

参考:https://zhidao.baidu.com/question/493957475787947812.html

举报

相关推荐

0 条评论