首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

>>>> 请问用jawind怎么获取dll中方法的返回值? <<<<

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

>>>> 请教用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();..
[解决办法]
楼上对

热点排行