I've got a dll, which exports function, which looks like this: MyClass::MyMethod(char*)
.
How do I use that through DllImport?
次のように DllImport を使用します。
[DllImport("MyNativeC++DLL.dll")]
private static extern void MyMethod(StringBuilder myCharPointerParameter);
C# から c++ 関数への char ポインターの受け渡しを参照してください。
静的な場合MyClass::MyMethod
は、簡単にエクスポートして p/Invoked できます (Eric の回答を参照)。
これがインスタンス メソッドの場合、事態はさらに難しくなります。C++ クラスをマーシャリングする方法。