Search code examples
.netc++pinvoke

P/Invoke a purely C++ library?


Is it possible to P/Invoke a pure C++ library, or does it have to be wrapped in C?


Solution

  • C++ libraries can be P/invoked, but you'll need to use "depends" to find the mangled method names (names like "@0!classname@classname@zz") and for instance methods use "ThisCall" calling convention in the p/invoke and pass the reference of the instance as the first argument (you can store the result of the constructor within an IntPtr).