使用jna在java中加载delphi dll [英] loading a delphi dll in java using jna

查看:172
本文介绍了使用jna在java中加载delphi dll的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个java新手,我正在尝试加载一个delphi DLL,并从中调用函数。



已经在PHP中使用了winbinder,但似乎无效:时,资源很少。



一些相关的Stack Overflow问题解释了您可能会遇到的一些问题:




I'm a java newbie and I'm trying to load a delphi dll, and call functions from it.

Already tried in php using winbinder but it seems to be useless: reloading dll in winbinder (php gui) crashes program

Anyway I have this simple java code, and I can't figure out how to make it work. There are some examples over the internet, but none seems to be working for me.

Dll is 32bit, so is my windows, jdk and Eclipse. Simples function to use would be GetDllVersion. I would really apriciate any help.

I can't even load it, here is first error (there are couple popups following):

Here is the code:

import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.NativeLong;
import com.sun.jna.Platform;
import com.sun.jna.*;

public class Main {

      static {
        try {
            System.load("C:/workspace/XmlDownlaoder/xxxxxxxDLL.dll");
        } catch (UnsatisfiedLinkError e) {
          System.err.println("Native code library failed to load.\n" + e);
          System.exit(1);
        }
      }

      public static void main(String argv[]) 
      {
        //how to call functions here? - there will be many functions, and final one should generate xml in return

      }
    }

EDIT: Native code library failed to load - this doesn't show on console.

解决方案

Don't load your DLL by hand, let JNA do the grunt work for it.

There are quite a few good resources when you search for Delphi JNA.

A few relevant Stack Overflow questions that explain some of the things you will probably bump into:

这篇关于使用jna在java中加载delphi dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆