/********************
由于无法上传附件,cds.exe请到csdn下载!
http://download.csdn.net/source/3317043
附件出处:http://home.no/aksoftware/ 第三个,QRes
********************/
import java.io.IOException;
/**
*
*修改分辨率
* @author cmxie
*/
public class ChangeDisplaySettings {
public static boolean change(int w,int h)
{
String cmd = "";
try {
if (WindowsOrLinux.getSystemType()) {// 判断系统:Window 系统
//附件为cds.exe文件。该文件是封装好的修改分辨率的小工具。直接调用传入参数即可。
cmd = " cmd "+System.getProperty("user.dir")+"/DownloadFileList/SOURCE/cds.exe /x "+w+" /y "+h;
Runtime.getRuntime().exec(cmd);
return true;
} else {// Linux 系统
//linux中使用命令 xrandr 来修改分辨率
cmd = " xrandr -s "+w+"x"+h;
Runtime.getRuntime().exec(cmd);
return true;
}
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
public static void main(String[] args) throws NativeException, IllegalAccessException{
ChangeDisplaySettings.change(1440,900);
}
}
/**
* 判断操作系统
* @author cmxie
*
*/
public class WindowsOrLinux {
/**
* 获取操作系统类型 true:windows false:linux
* @return
*/
public static boolean getSystemType()
{
String osName = System.getProperty("os.name");
if(osName!=null && !"".equals(osName)){
if (osName.matches("^(?i)Windows.*$")) {// Window 系统
return true;
}else
{
return false;
}
}
return true;
}
}
/**************** *java风暴* 63353324 技术联盟*******************/