資源簡(jiǎn)介
java和dll交互
參考文章:https://www.jianshu.com/p/7f9b6d3af297
代碼片段和文件信息
package?com.test.hellojna;
import?com.sun.jna.ptr.IntByReference;
import?com.test.hellojna.HelloInterface.CB_MY;
/**
?*?Hello?world!
?*
?*/
public?class?App?
{
????public?static?void?main(?String[]?args?)
????{
???? HelloInterface?myinterface?=?Hellobase.getInstance();
????
???? int?aa?=?10;
???? final?IntByReference?aa_valRef?=?new?IntByReference(aa);
???? myinterface.fun1(aa_valRef);
???? System.out.println(“########“?+?aa_valRef.getValue());
????
???? final?HelloInterface.MyStruct.ByReference?arg1?=?new?HelloInterface.MyStruct.ByReference();
????arg1.nVal1?=?11;
????arg1.nVal2?=?22.22f;
????myinterface.fun2(arg1);
???? System.out.println(“************“?+?“nVal1=“?+?arg1.nVal1?+?“nVal2=“?+?arg1.nVal2);
????
???? myinterface.fun3(new?CB_MY()?{
???? public?int?invoke(int?nValint?fVal)?{
???? ???? System.out.println(“cb_my:“?+?nVal+?“?“?+?fVal);
???? ????return?0;
???? }
???? })?;
???? System.out.println(“============“);
????}
}
評(píng)論
共有 條評(píng)論