基本上,我只需要编写一个简单的 java 程序来检测我本地安装的 Internet Explorer 的版本。
有 javascript 代码,但它在您的浏览器中运行。我想要的是这样的代码:
public class VersionTest
{
public static void main(String[] args)
{ System.out.println("you IE Version is:" + getIEVersion());
}
public static String getIEVersion()
{ //implementation that goes out and find the version of my locally installed IE
}
}
我该怎么做?谢谢
最佳答案
您可以使用 Internet Explorer 注册表项
作为版本。您可以使用 Runtime 从 java 执行 Reg Query
类(class)。 Reg Query 是一个命令行工具,用于在 windows 中查询注册表项。
Process p = Runtime.getRuntime().exec("reg query \"HKLM\\Software\\Microsoft\\Internet Explorer\" /v Version");
完整代码:
ArrayList<String> output = new ArrayList<String>()
Process p = Runtime.getRuntime().exec("reg query \"HKLM\\Software\\Microsoft\\Internet Explorer\" /v Version");
BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()),8*1024);
BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream()))
String s = null;
System.out.println("Here is the standard output of the command:\n");
while ((s = stdInput.readLine()) != null)
output.add(s)
String internet_explorer_value = (output.get(2));
String version = internet_explorer_value.trim().split(" ")[2];
System.out.println(version);
输出 = 9.0.8112.16421
reg query
在我的命令提示符下的输出
HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer
Version REG_SZ 9.0.8112.16421
关于java - 你能写 Java 代码来检查你本地 Internet Explorer 的版本吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8917645/