简体   繁体   English

如何从jna或其他库访问vb.net本机dll文件的类和方法

[英]How to access classes and methods of vb.net native dll file from jna or other library

What I have 我有的
a) I have used jna library. a)我使用过jna库。
b) My dll is vb.net native dll file. b)我的dll是vb.net本机dll文件。
c) You can check this link for more about dll link c)您可以查看此链接以获取有关dll 链接的更多信息

My source code is following 我的源代码如下

Interface 接口

package com.dll.lib;

import com.sun.jna.Library;
import com.sun.jna.Native;

public interface BrowseControl extends Library {
    BrowseControl instance = (BrowseControl)Native.loadLibrary("Vertex FXBOAPI10.5.9", BrowseControl.class);
}

Class

package com.dll.main;

import com.dll.lib.BrowseControl;

public class MainTest {

    public static void main(String[] args) {
        BrowseControl control=BrowseControl.instance;
            System.out.println("Brwoser: "+control.getClass());
        }  
    }

}

This code is working. 这段代码正在运行。

What I want 我想要的是
a) how to access their classes and method from dll in java programming language? a)如何在java编程语言中从dll访问他们的类和方法?

b) how to reference the {VertexFX Backoffice API} Dll, then define Object of type CVertexFXBOAPI class, after that call the methods Object.SetLoginInfo and Object.Login b)如何引用{VertexFX Backoffice API} Dll,然后定义类型为CVertexFXBOAPI类的Object,之后调用方法Object.SetLoginInfoObject.Login

Thanks 谢谢

Yo can use native code from shared library via JNI. Yo可以通过JNI使用共享库中的本机代码。 JNI provides bridge between Java and your code. JNI提供了Java和代码之间的桥梁。 However, you have to make sure that you keep naming convention for your native routines. 但是,您必须确保为本机例程保留命名约定。

In your case (where you have DLL with native code you want to call) you can go via JNI wrapper that will code the code. 在你的情况下(你想要调用本机代码的DLL)你可以通过JNI包装器来编写代码。 This way, you can leave DLL as it is. 这样,您可以保留DLL原样。

Take a look here for a sample code where: 看看这里的示例代码,其中:

http://jnicookbook.owsiak.org/recipe-No-018/ http://jnicookbook.owsiak.org/recipe-No-018/

This is not exactly what you are looking for (as the code is for macOS/Linux) but the schema will be very similar. 这不是您正在寻找的(因为代码适用于macOS / Linux),但架构将非常相似。

Your JNI wrapper (called from Java) - this will be a native code - will load library you already have (one that is inside DLL produced by somebody else). 你的JNI包装器(从Java调用) - 这将是一个本机代码 - 将加载你已经拥有的库(一个在其他人生成的DLL内)。 Then, you will need to call a function from that DLL. 然后,您需要从该DLL调用一个函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM