日期:2014-05-20  浏览次数:20727 次

求,jna调用动态库,不能正常输出,输出的全是日志,帮帮我
各位大哥哥大姐姐们,我这里有一个问题一直没有做出来,请帮帮我,很急,我用的是jna调用动态库,代码是

public interface DMISYSDLL extends StdCallLibrary{
DMISYSDLL INSTANCE=(DMISYSDLL)Native.loadLibrary("SysEnv",DMISYSDLL.class);
public static class FilePathParam extends Structure{
public byte PathBuf;
public byte Discript;
public byte VarDiscript;
public int type;
public static class ByReference extends FilePathParam implements Structure.ByReference{};
public static class ByValue extends FilePathParam implements Structure.ByValue{};
}
public static class DMISYSPARAM extends Structure{
//对应结构类
public NativeLong SysIdentify;
public byte SysIdentifyCode;
public NativeLong LocalIdentify;
public short printtype;
public float SysInertia;
//设备认证编号
public FilePathParam.ByValue DevAttestationNo=new FilePathParam.ByValue();
//监测站名称
public FilePathParam.ByValue StationName=new FilePathParam.ByValue();
//系统审核编号
public FilePathParam.ByValue SysAuditingNo=new FilePathParam.ByValue();
//本地数据源
public FilePathParam.ByValue LocalODBC=new FilePathParam.ByValue();
//远程数据源
public FilePathParam.ByValue RemoteODBC=new FilePathParam.ByValue();
//QA2系统主路径, 非文件
public FilePathParam.ByValue QA2SysPath=new FilePathParam.ByValue();
//QA2系统配置文件主路径, 非文件
public FilePathParam.ByValue QA2CfgPath=new FilePathParam.ByValue();
//QA2系统升级文件路径, 非文件
public FilePathParam.ByValue QA2UpdatePath=new FilePathParam.ByValue();
//QA2系统辅助文件路径, 非文件
public FilePathParam.ByValue QA2AuxPath=new FilePathParam.ByValue();
//下面的描述是制定的文件,非路径
//例如:KFreePrt_TabPath="D:\\QAII\\system\\bin\\prt_freespeed.table"
//打印库路径
//发分仪通讯口
public FilePathParam.ByValue VoicePortPath=new FilePathParam.ByValue(); //声级仪通讯口
//
public FilePathParam.ByValue CXKManPath=new FilePathParam.ByValue(); //车型库管理库
public FilePathParam.ByValue ParaManPath=new FilePathParam.ByValue(); //配置管理工具库
//
public FilePathParam.ByValue LossFilePath=new FilePathParam.ByValue(); // public FilePathParam.ByValue BPQFactory=new FilePathParam.ByValue(); //变频器/速度转换系数=速度/频率
////////////////////////////////////////
public FilePathParam.ByValue FileResultPath=new FilePathParam.ByValue(); //文件联网,结果文件
////////////////////////////////////////
public FilePathParam.ByValue FileNetWorkLibPath=new FilePathParam.ByValue(); //文件联网库
////////////////////////////////////////
public FilePathParam.ByValue Res=new FilePathParam.ByValue(); //保留
public static class ByReference extends DMISYSPARAM implements Structure.ByReference{};
public static class ByValue extends DMISYSPARAM implements Structure.ByValue{};
}
public int GetSysEnv(DMISYSPARAM.ByReference a);
}

下面是实现代码,
package txxt;


import txxt.DEVHEADDLL.DEV_HEAD;
import txxt.DMISYSDLL.DMISYSPARAM;
import txxt.DMISYSDLL.FilePathParam;


public class TeHpo {

/**
* @param args
* @throws Exception 
*/
public static void main(String[] args) throws Exception {
String sql = "select * from tb_all_result_save where id=?";
Connection conn = BaseDao.getConnection();
PreparedStatement pst = null;
ResultSet rs = null;

pst = conn.prepareStatement(sql);
pst.setInt(1, 11527);
rs = pst.executeQuery();
while(rs.next()){
InputStream in = rs.getBinaryStream("resultinfo");
byte[] buf = new byte[1024 * 150];
in.read(buf);
DEV_HEAD.ByReference devhead = new DEV_HEAD.ByReference();
int n=DEVHEADDLL.INSTANCE.ParseStdHead(buf, devhead);
System.out.println(n+"+++++++++++++");
String IDInfo="";
if(n>0){


DMISYSPARAM.ByReference dmisy=new DMISYSPARAM.ByReference();