import java.util.ArrayList; import java.util.List; import com.sun.jna.Structure; public class MyStructure extends Structure { public static class ByReference extends MyStructure implements Structure.ByReference {} public static class ByValue extends MyStructure implements Structure.ByValue {} public float outputSim; @Override protected List<String> getFieldOrder() { List<String> Field = new ArrayList<String>(); Field.add("outputSim"); return Field; } }
import com.sun.jna.Library; import com.sun.jna.Native; public interface className extends Library { className INSTANCE = (className) Native.loadLibrary(dll路徑, className.class); int interfaceName(String A, String B, MyStructure.ByReference ref); }
ByReference ref = new ByReference(); Integer state = className.INSTANCE.interfaceName(A, B, ref);
//ref.(c++的接口的輸出結果參數名稱),獲取結果