0

I've got a dll, which exports function, which looks like this: MyClass::MyMethod(char*).

How do I use that through DllImport?

4

2 に答える 2

2

次のように DllImport を使用します。

[DllImport("MyNativeC++DLL.dll")]
private static extern void MyMethod(StringBuilder myCharPointerParameter);

C# から c++ 関数への char ポインターの受け渡しを参照してください。

于 2012-08-02T22:28:20.323 に答える
0

静的な場合MyClass::MyMethodは、簡単にエクスポートして p/Invoked できます (Eric の回答を参照)。

これがインスタンス メソッドの場合、事態はさらに難しくなります。C++ クラスをマーシャリングする方法

于 2012-08-02T22:33:21.220 に答える