JAVA JNA调用动态链接库

发布时间:2024年01月15日

?1.JAVA 中pom坐标的引入

   <dependency>
            <groupId>net.java.dev.jna</groupId>
            <artifactId>jna-platform</artifactId>
            <version>5.2.0</version>
   </dependency>

2.首先根据系统判断动态连接库的调用的类型

 String os = this.systemParam();
        if (os.toLowerCase().startsWith("windows")) {
            return LzjStartLibrary.LIBRARY.NET_DVR_StartDVRRecord(lUserID, lChannel, lRecordType);
        }
        return LzjSoStartLibrary.LIBRARY.NET_DVR_StartDVRRecord(lUserID, lChannel, lRecordType);

?

? 3.接口调用方式

public interface LzjStartLibrary extends Library {

        Boolean NET_DVR_StartDVRRecord(int lUserID, int lChannel, int lRecordType);
 
        String dataDir = getConfig("system.win-dir");

        LzjStartLibrary LIBRARY = Native.loadLibrary(dataDir, LzjJnaServiceImpl.LzjStartLibrary.class);
    }

    public interface LzjSoStartLibrary extends Library {

        boolean NET_DVR_Init();

        Boolean NET_DVR_StartDVRRecord(int lUserID, int lChannel, int lRecordType);
        String dataDir = getConfig("system.data-dir");
        LzjSoStartLibrary LIBRARY = Native.loadLibrary(dataDir, LzjJnaServiceImpl.LzjSoStartLibrary.class);
    }

文章来源:https://blog.csdn.net/qq_41324075/article/details/135551733
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。