how to call methods with leading underscore and traling @ in JNA

喜欢而已 提交于 2019-12-12 18:24:04

问题


I have to call methods in dll but their names are like these _setParameterX@12 and _getParameterX@20 using Java Native Access. How can I properly use FunctionMapper or StdCallFunctionMapper? How do I invoke these functions? The jna documentation is a little vague to me.


回答1:


Those functions use the stdcall calling convention. The suffix indicates the size of the incoming arguments on the stack.

You should use the StdCallFunctionMapper to automatically generate the appropriate mappings. Create options similar to those used in the W32API options (the function mapper there automatically chooses a -W or -A suffix for W32 API functions). Pass your new options map to your invocation of Native.loadLibrary.

In addition, make sure you implement the StdCallLibrary interface so that the appropriate calling convention is used when calling the functions.



来源:https://stackoverflow.com/questions/12578457/how-to-call-methods-with-leading-underscore-and-traling-in-jna

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!