【发布时间】:2026-01-25 03:15:02
【问题描述】:
我在用 c++ 创建的 dll 中有这个
extern "C" __declspec(dllexport)
char* __stdcall hh()
{
char a[2];
a[0]='a';
a[1]='b';
return(a);
}
这就是我尝试在 c# 中处理代码的方式
[DllImport(@"mydll.dll",CharSet = CharSet.Ansi,CallingConvention = CallingConvention.StdCall)]
public static extern IntPtr hh();
static void Main(string[] args)
{
IntPtr a = hh();
//How to proceed here???
}
}
帮助进一步进行。
【问题讨论】:
-
你的问题到底是什么?
-
我想在 c# 中打印从 c++ 代码返回的数组
标签: c# c++ marshalling