2 qq 16334413 qq_16334413 于 2016.09.07 10:16 提问

JNA如何对LPHANDLE类型参数的处理 10C

请问使用JNA调用dll动态链接库时,类似下面这个方法,phUSBContext这个参数该怎么处理
DWORD CeInitUSBLayer(LPHANDLE phUSBContext, LPDWORD dwSysErr)
Description: Init USB Layer
phUSBContext: USB Layer Context pointer. This parameter must be used as
parameter for others USB API on the same context resource
dwSysErr: 0= NO error , otherwise system error ( GetLastError(..) )
Return Value: 0 = NO Error , for other values see Error Table in CePrnLibDef.h

1个回答

u010974488
u010974488   2016.09.08 20:03

用结构体
1. 定义结构体
public static class PROGNAME extends Structure{
public static class ByReferenceb extends PROGNAME
implements Structure.ByReference{}
public static class ByValueb extends PROGNAME implements
Structure.ByValue{}
public byte[] comment;
@Override
protected List getFieldOrder() {
return Arrays.asList(new String[] {"comment"});
}
}
2. 调用
PROGNAME.ByReferenceb rs= new PROGNAME.ByReferenceb();
rs.comment =new byte[52];
JNARemoteService.getService().doservice(rs);

Csdn user default icon
上传中...
上传图片
插入图片