问题
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