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.
来源:https://stackoverflow.com/questions/8728873/accessing-dll-methods-with-contain-mulitple-classes-using-jna