使用JNA访问包含多个类的DLL方法 [英] Accessing DLL methods with contain mulitple classes using JNA
问题描述
那么总而言之,如何使用JNA在DLL中达到这个方法?
CDrawControl.DrawCtl.SaveFile()
这可能是一件非常简单的事,我错过了。
public class ReadDLL {
public interface ChemDrawCtl12 extends Library {
CDrawControl INSTANCE =(CDrawControl)Native.loadLibrary(
(Platform.isWindows )?CDrawControl:CDrawCtl12LinuxPort),
CDrawControl.class);
void DrawCtl.SaveAs(); //这是错误的,但显示我正在努力做什么!
}
您最有可能需要使用一个COM包装,尝试JACOB或com4j。这些项目可以扫描接口定义文件并生成相应的Java对象。
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!!
}
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.
这篇关于使用JNA访问包含多个类的DLL方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!