读书人

gt;gt;gt;gt; 请问用jawind怎么获取dll中方

发布时间: 2011-12-28 22:45:21 作者: rapoo

>>>> 请教用jawind如何获取dll中方法的返回值? <<<<
在DLL中有一个方法GetBalance(String snh, String pwd) 返回值为String

请问我这样写
try {
FuncPtr GetBalance = new FuncPtr("Users.DLL", "GetBalance");
NakedByteStream nbs = new NakedByteStream();
LittleEndianOutputStream leos = new LittleEndianOutputStream(nbs);
leos.writeStringUnicode(smsProperties.getUserID());
leos.writeStringUnicode(smsProperties.getSerialPassword());
GetBalance.invoke("IGGI:I:", 16, nbs, null, ReturnFlags.CHECK_FALSE);
} catch (COMException e) {e.printStackTrace();}

下面该如何获取GetBalance的返回值呢?

[解决办法]
invoke调用后将输出一组字节数组,对这个数组进行处理就可以了

Java code
..byte[] result = funcPtr.invoke(..);// wrap result in a LittleEndianInputStreamLittleEndianInputStream leis = new LittleEndianInputStream(new ByteArrayInputStream(result));// any [retval] values are placed firstint retVal = leis.readInt();// and then follows any [out] valuesint outVal = leis.readInt();..
[解决办法]
楼上对

读书人网 >J2SE开发

热点推荐