通过JNA在Borland DLL中查找函数时出错

图腾

这是我的一个运行示例DLLService

import com.sun.jna.Native;
import com.sun.jna.win32.StdCallLibrary;

public class DLLService {

public DLLService() throws Exception {
    System.out.println("version = " + version()  + "\n");
    testEvaluate();
}

public void testEvaluate() {
    System.out.println(this.loadFile("file", 1));
    int[] barre = new int[] {0, 1, 2, 3, 4};
    int[] result = new int[]{};
    evaluateParty(barre.length, barre, result, 1);
    System.out.println(result);
}

public int version() {
    return GDLL.INSTANCE.LireNoVersion();
}

public int loadFile(String tslName, int pdwNoSess) {
    return GDLL.INSTANCE.ChargerFichier();
}



public interface GDLL extends StdCallLibrary  {
    GDLL INSTANCE = (GDLL) Native.loadLibrary("tsr32_mini", GDLL.class);

    int LireNoVersion();
    int ChargerFichier();
}
}

函数没有问题,version()但没有loadFile(...),我有一个例外:

线程“主”中的异常java.lang.UnsatisfiedLinkError:查找函数'EvaluerPartie'时出错:

在com.sun.jna.Function。(Function.java:212)在com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:541)在com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:518)位于com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:504)位于com.sun.jna.Library $ Handler.invoke(Library.java:220)位于com.sun.proxy。$ Proxy0.EvaluerPartie(未知源) )位于DLLService.evaluateParty(DLLService.java:29)于DLLService.testEvaluate(DLLService.java:16)于DLLService。(DLLService.java:9)于ProblemsIsolator.main(ProblemsIsolator.java:53)

我已经搜索了,但没有找到任何有效的方法(更改类型,参数,名称等)。下面是函数L的原型:DWORD ChargerFichier (LPSTR chNom, DWORD *pdwNoSess)

编辑:即使使用名称映射器后,同样的错误;LireVersion适用于

public void testFunctionMapper() throws Exception {
        FunctionMapper mapper = StdCallLibrary.FUNCTION_MAPPER;
        NativeLibrary lib = NativeLibrary.getInstance("tsr32_mini");

        Method[] methods = {
                GDLL.class.getMethod("LireNoVersion",
                                        new Class[] { String.class, int.class }),
                GDLL.class.getMethod("ChargerFichier",
                                        new Class[] { String.class, int.class }),
        };

        for (int i=0;i < methods.length;i++) {
            String name = mapper.getFunctionName(lib, methods[i]);
            lib.getFunction(name, StdCallLibrary.STDCALL_CONVENTION).getName();
        }
}

而且,一个依赖项工作者向我很好地介绍了这些方法。

JFPicard

好像在该链接中起作用:如何获得对DLL的Java JNA调用以获取参数中返回的数据?,我可以看到您对的定义ChargerFichier缺少参数。

也许定义应该是这样的:

int ChargerFichier(PointerByReference chNom, IntByReference pdwNoSess);

也许此链接也可以为您提供帮助:http : //www.viaboxx.de/code/java-interoperation-with-a-native-dll-using-jna/

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

通过C DLL调用函数时出错

通过JNA调用dll函数,如何处理Java中通过指针传递的地址?

使用JNA调用CreateFile会给出UnsatisfiedLinkError:查找函数'CreateFile'时出错:找不到指定的过程

在 Selenium 中尝试通过 Xpath 查找元素时出错

Delphi Dll函数中的Java JNA映射

通过逐步函数执行lambda时出错

通过函数传递模板参数时出错

使用“ enter”键通过Wikipedia API查找文章时出错

通过 xgboost 查找 n_estimators 时出错

Borland中的多线程

Visual Studio Borland dll错误

JNA 中的 Oleacc dll 支持

如何使用二维指针通过 JNA 调用 C 函数?

使用Java(JNA)映射Delphi DLL的函数

通过构造函数创建bean实例化bean时出错

通过modules.exports调用javascript函数时出错

从 Python 调用 Windows DLL 函数时出错

从非托管dll调用函数时出错

从Python调用C DLL函数时出错

使用 Java 进程通过 JNA 从具有大量类的非常复杂的 C++ Win32 DLL 调用方法

将C-DLL中的回调函数转换为Java JNA

“打开终端时出错:未知。” 通过 Python 在 SSH 服务器中运行命令时出错

在Delphi中通过引用传递的指针(从DLL导入函数)

尝试访问 JNA 函数时出现 IllegalArgumentException

使用gitlab CI通过CLI创建lambda函数时出错(解析参数'--zip-file'时出错:无法加载paramfile)

通过SDK在GCP中创建服务帐户时出错

尝试通过Pycharm中的pip安装numpy时出错

尝试通过提交从Mercury回购中安装cocoapod时出错

在Go中通过代理获取URL时出错