gpt4 book ai didi

c# - 如何从 C# 中的 dll 导入访问 char***

转载 作者:行者123 更新时间:2023-11-30 12:36:48 24 4
gpt4 key购买 nike

我在 win32 dll 中有一个函数,签名为:

void func1(int a, char*** outData)

int a --> 输入参数
char*** outData --> 输出参数 - 指向 char 字符串数组的指针


知道如何使用 dll 导入在 C# 中访问它以及签名应该是什么。

最佳答案

对于像三重指针这样的复杂类型,我发现最好的方法是简单化并将其编码为 IntPtr

[DllImport("Some.dll")]
private static extern void func1(int a, out IntPtr ptr)

一旦此函数返回 IntPtr 值将实质上代表一个 char**

使用该值几乎是不可能的,因为我们不知道长度。您需要更改函数签名以传回数组的长度,然后才能在托管代码中使用它。

关于c# - 如何从 C# 中的 dll 导入访问 char***,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2529471/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com