how to use cdecl callback with pinvoke

后端 未结 2 657
青春惊慌失措
青春惊慌失措 2021-02-08 21:12

I have a c library that has cdecl callbacks. How can I use these from c#.

Everything seems to say that they must be stdcall callbacks

to be clear:



        
2条回答
  •  梦毁少年i
    2021-02-08 21:58

    1. Compile with .NET 2.0, use 2005 compiler!!
    2. Reverse the argument direction.

    It works due to some safeguard code added by the 2005 compiler.

    EDIT: Don't try this if you can possibly make a shim in native code.

提交回复
热议问题