0

C# dll から C++/CLR dll の関数を呼び出そうとしています。->これはかなりうまくいっています。

私が直面している問題は、C# から C++/CLR の関数に渡す必要があるパラメーターが C++ で正しく到着しないことです。

最後に、文字列の配列といくつかのブール値パラメーターを C# から C++/CLR に渡す必要があります。

これまでに行ったこと/試したこと:

私のC++/CLR部分は次のようになります。

__declspec(dllexport) void __cdecl BCFConsumer::Translatehelper(char **IDs, int len, bool blinking, bool highlight, bool showOnly, bool zoom){
    vector<std::wstring> IDsVec;
    std::wstring tmp;
    msclr::interop::marshal_context context;

    for (int i = 0; i < len; i++) {
        IDsVec.push_back(std::wstring(IDs[i], IDs[i] + strlen(IDs[i])));
    }

    ShowElements(IDsVec, blinking, highlight, showOnly, zoom);
}

私のC#(dll-import)部分は次のようになります:

[DllImport("BCF.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "?Translatehelper@BCFConsumer@@QEAAXPEAPEADH_N111@Z")]
        public static extern void Translatehelper(string[] IDs, int size, bool blinking, bool highlight, bool showOnly, bool zoom);

C# での関数呼び出しは次のようになります。

    public void btnshow_Click(object sender, RoutedEventArgs e)
            {
                IDs.Add("0znBcjLrbFBxuK9yivEUEO");
                IDs.Add("0cLtxHLKfA9x58$Mi2DnUp");
                Translatehelper(IDs.ToArray(), IFCIDs.Count, _blinking, _highlight, _showOnly, _zoom);
            }

ID は次のように定義されます。

public List<string> IFCIDs = new List<string>();
4

0 に答える 0