最近项目里使用java调用dll动态库,因此研究了一下这方面的东西。

 

使用的工具包如下

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

 

调用方法也很简单

public class Main {

    public static void main(String[] args) {
        String url = "http://********.htm?";
        String czqhnm = "0000000000";
        String dwbm = "05301";
        String ywlx = "000020";
        String codeno = "001";

        String msg = CLibrary.INSTANCE.getCheckCode(czqhnm, dwbm, ywlx, codeno);

        url = url + "czqhnm=" + czqhnm + "&dwbm=" + dwbm + "&ywlx=" + ywlx + "&codeno=" + codeno + "&" + msg;

        System.out.println(url);

    }

    public interface CLibrary extends Library {
        // FS_CheckCode是动态库名称,前面的d://test//是路径
        CLibrary INSTANCE = (CLibrary) Native.loadLibrary("d://test//FS_CheckCode", CLibrary.class);

        // 我们要调用的动态库里面的方法。
        String getCheckCode(String czqhnm, String dwbm, String ywlx, String codeno);
    }
}

 

相关文章:

  • 2022-12-23
  • 2021-08-31
  • 2022-12-23
  • 2021-06-27
猜你喜欢
  • 2021-12-21
  • 2021-12-11
  • 2022-12-23
  • 2022-01-17
  • 2021-05-18
  • 2021-09-10
  • 2022-12-23
相关资源
相似解决方案