0

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

How do I use that through DllImport?

Eric J.
  • 147,927
  • 63
  • 340
  • 553
Arsen Zahray
  • 24,367
  • 48
  • 131
  • 224

2 Answers2

2

You use DllImport, like this:

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

See Passing char pointer from C# to c++ function

Community
  • 1
  • 1
Eric J.
  • 147,927
  • 63
  • 340
  • 553
0

If MyClass::MyMethod is static, it can be exported and p/Invoked with ease (see Eric's answer).

If this is an instance method, things get a whole lot more difficult. How to Marshal a C++ Class.

Tergiver
  • 14,171
  • 3
  • 41
  • 68