c# 使用 const char **aString 参数导入 DLL 函数

问题描述 投票:0回答:0

我从我的 C++ dll 导出了以下内容:

extern "C" __declspec(dllexport)
uint64_t aFunction(const char **aString) noexcept
{
    *aString = "Pointer to a string";
    return 123;
}

现在,我想在我的 C# 应用程序中使用该函数,但如何在 C# 中正确使用

const char **
参数?我尝试了以下,但它不正确:

[DllImport("GOlinkLibrary.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.Cdecl)]
private static extern UInt64 aFunction([MarshalAs(UnmanagedType.LPUTF8Str)] string aString);

使用示例:

string aString = "abc";
aFunction(aString);
Text = aString; // Remains "abc"
c# dll dllimport
© www.soinside.com 2019 - 2024. All rights reserved.