Accessing DLL methods with contain mulitple classes using JNA

你。 提交于 2019-12-01 12:23:36

问题


I am new to accessing DLLs from Java using JNA,so forgive me if this is obvious to everyone! I need to access methods from a class within a DLL(which was written in VB) and cannot do this by just loading the library as I see how to access a class within it I.e. the DLL is called CDrawControl.dll, but the class within the DLL I need to access is DrawCtl. So I need to get an instance of the DrawCtl class. So all in all, how to I reach this method in the DLL using JNA?

I.e. CDrawControl.DrawCtl.SaveFile()

It is probably something very simple I am missing.

public class ReadDLL {
    public interface ChemDrawCtl12 extends Library {
    CDrawControl INSTANCE = (CDrawControl) Native.loadLibrary(
            (Platform.isWindows() ? "CDrawControl" : "CDrawCtl12LinuxPort"),
            CDrawControl.class);

    void DrawCtl.SaveAs(); // this is wrong but shows what I am trying to do!!
}

回答1:


You most likely need to use a COM wrapper, try JACOB or com4j. Those projects can scan an interface definition file and generate corresponding Java objects.



来源:https://stackoverflow.com/questions/8728873/accessing-dll-methods-with-contain-mulitple-classes-using-jna

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!