本文介绍了如何在JNA中使用前导下划线和traling @来调用方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须在dll中调用方法,但它们的名称类似于使用Java Native Access的这些_setParameterX @ 12和_getParameterX @ 20.如何正确使用FunctionMapper或StdCallFunctionMapper?如何调用这些功能? jna文档对我来说有点模糊.

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.

推荐答案

这些函数使用stdcall调用约定.后缀表示堆栈上传入参数的大小.

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

您应该使用StdCallFunctionMapper自动生成适当的映射.创建与 W32API中使用的选项相似的选项选项(那里的函数映射器会自动为W32 API函数选择-W或-A后缀).将新选项映射传递给您对 Native.loadLibrary .

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.

此外,请确保实现StdCallLibrary接口,以便在调用函数时使用适当的调用约定.

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

这篇关于如何在JNA中使用前导下划线和traling @来调用方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 02:50