java - Native.loadLibrary 中的选项

标签 java jna

我从事 JNA 工作已经有一段时间了。但有一件事我没明白。例如,加载库时:

Map<String, Integer> options = new HashMap<String, Integer>();
options.put(Library.OPTION_CALLING_CONVENTION, StdCallLibrary.STDCALL_CONVENTION);
this.EDSDK = (EdSdkLibrary) Native.loadLibrary("EDSDK/dll/EDSDK.dll", EdSdkLibrary.class, options);

上面的选项到底是什么?

api说:

public static Object loadLibrary(String name, Class interfaceClass, Map options)

Load a library interface from the given shared library, providing the explicit interface class and a map of options for the library. If no library options are detected the map is interpreted as a map of Java method names to native function names. If name is null, attempts to map onto the current process.

上面的库选项图是什么意思?

最佳答案

这是一张包含库选项的 map 。其中一个选项是函数映射器。 您可以在下面找到一个示例:

    System.setProperty("jna.library.path","SiUSBXp.dll");
    HashMap<String, StdCallFunctionMapper> optionMap = new HashMap<String,    StdCallFunctionMapper>();
    StdCallFunctionMapper myMapper = new StdCallFunctionMapper();
    optionMap.put(Library.OPTION_FUNCTION_MAPPER, myMapper);
    INSTANCE = (SiUSBXp) Native.loadLibrary("SiUSBXp", SiUSBXp.class, optionMap);

关于java - Native.loadLibrary 中的选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16456499/

相关文章:

java - 渲染具有大字体大小的字形 vector

Java JNA编写win32 API的自定义COM接口(interface)

Java JNA 调用 dll Advapi32 中的函数 "InitiateSystemShutdown"不起作用

java - 在资源路径中找不到 JNA native 支持 (/com/sun/jna/linux-arm/libjnidispatch.so)

java - 如何在JNA中映射Windows API CredWrite/CredRead?

Java JNA-Jar应用程序在32位Windows系统中挂起

java - 从 Excel 文件读取数字 - Java - Swing

java - 通过对象序列化流发送具有不同字段的相同对象

java - 在 Java 中创建网格

java - 如何用java解决selenium webdriver中的超时错误?