日期:2014-05-20 浏览次数:21013 次
public int Max(int a,int b){
JNative n = null;
try {
n = new JNative("Project1.dll", "Calc");
n.setRetVal(Type.INT);
// 设置参数
int i = 0;
n.setParameter(i++, Type.INT, a + "");
n.setParameter(i++, Type.INT, b + "");
n.invoke();
return Integer.parseInt(n.getRetVal());
} catch (NativeException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
if(n != null){
try {
n.dispose();
} catch (NativeException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
return 0;
}
public int topc(){
JNative n = null;
try {
//设置c++里的对应函数
n = new JNative("Project1.dll", "ToPC");
//设置返回类型
n.setRetVal(Type.INT);
// 设置参数
int i = 0;
n.setParameter(i++, "c:\\");
n.invoke();
return Integer.parseInt(n.getRetVal());
} catch (NativeException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
if(n != null){
try {
n.dispose();
} catch (NativeException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
return 0;
}