jna 调用dll 参数上的返回值怎么获取

2021-03-30 19:59发布

4条回答
studentaaa
2021-04-18 10:32

工作中需要用java调用dll,并获取信息

代码如下:

1 function JavaCall(InS, OutS: PChar): Integer; stdcall;
2 var
3   s: string;
4   begin
5   ShowMessage('您传入的内容:'+InS);
6   s := 'DLL返回内容';
7   OutS := PChar(s);
8   Result := 999;
9 end;

 

    public interface CLibrary extends Library {
        CLibrary INSTANCE = (CLibrary) Native.loadLibrary("testdll", CLibrary.class); // 引入库文件

        public int JavaCall(String s1, byte[] s2);
    }    
    public static void main(String[] args) {        byte[] aaa = new byte[100];
        System.out.println("java call dll result = "+CLibrary.INSTANCE.JavaCall("ttttt", aaa));
        System.out.println("aaa="+new String(aaa));
    }


一周热门 更多>