gpt4 book ai didi

java - Native.loadLibrary 中的选项

转载 作者:行者123 更新时间:2023-12-04 04:58:22 26 4
gpt4 key购买 nike

我一直在做 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);
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 of options for the library是什么意思?

最佳答案

这是一张包含图书馆选项的 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com