【发布时间】:2010-03-27 13:43:01
【问题描述】:
我在 win32 dll 中有一个函数,签名为:
void func1(int a, char*** outData)
int a --> 输入参数
char*** outData --> 输出参数 - 指向 char 字符串数组的指针
知道如何在 C# 中使用 dll 导入和签名来访问它。
【问题讨论】:
我在 win32 dll 中有一个函数,签名为:
void func1(int a, char*** outData)
int a --> 输入参数
char*** outData --> 输出参数 - 指向 char 字符串数组的指针
知道如何在 C# 中使用 dll 导入和签名来访问它。
【问题讨论】:
对于像三指针这样的复杂类型,我发现最好的方法是简单化并将其编组为 IntPtr
[DllImport("Some.dll")]
private static extern void func1(int a, out IntPtr ptr)
一旦此函数返回 IntPtr 值将实质上表示 char**。
使用该值几乎是不可能的,因为我们不知道长度。您需要更改函数签名以传回数组的长度,然后才能在托管代码中使用它。
【讨论】: