How to get char** using C#? [duplicate]

孤者浪人 提交于 2019-11-30 12:06:58

I think you might need to use Marshal.

var a = (char*)Marshal.StringToCoTaskMemAuto("myString");
char** = &a;

This is just a guess because I don't have a library that takes char** so I haven't been able to try it.

The equivalent of C's char** is a fully-pinned byte[][] in C# (and by fully-pinned I mean the outer array AND all inner arrays). If you want to pass C# strings you'll have to convert them to byte arrays, for instance with Encoding.ASCII.GetBytes.

Can you change the DllImport declaration parameter type to StringBuilder[]? Then you can call the function like:

StringBuilder[] args = new StringBuilder[] { };
start(args);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!