P/Invoke a purely C++ library?

前端 未结 2 1776
無奈伤痛
無奈伤痛 2020-12-19 13:11

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

2条回答
  •  借酒劲吻你
    2020-12-19 13:41

    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).

提交回复
热议问题