package com.sbr.nsiimp.analysis.action;
/**
* @author <a href="mailto:foohsinglong@gmail.com">kevin.long</a>
* @description Java获取系统软件安装列表,代码核心来自网上,主要通过Runtime实现,
* 用JNI也行,解决乱码问题
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextPane;
public class SystemSoftware {
private JFrame f = new JFrame("本系统已经安装的软件列表");
private JTextPane textPane = new JTextPane();
private MyTable myTable=new MyTable();
public static Charset charset = Charset.forName("GBK");
public SystemSoftware() {
f.setLocation(300, 200);
f.setSize(800,500);
JScrollPane jScrollPane = new JScrollPane(myTable.getTable());
f.add(jScrollPane);
f.setVisible(true);
f.setDefaultCloseOperation(f.EXIT_ON_CLOSE);
try {
check();
} catch (Exception e) {
e.printStackTrace();
}
}
private void check() throws Exception {
textPane.setText("您已经安装的软件:");
Runtime runtime = Runtime.getRuntime();
Process process = null;
Process process1 = null;
//64位
process = runtime.exec("cmd /c reg query HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\");
//32位
process1 = runtime.exec("cmd /c reg query HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\");
//HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall
BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream(),"GBK"));
BufferedReader in1 = new BufferedReader(new InputStreamReader(process1.getInputStream(),"GBK"));
String string = null;
String s3
/**
* @author <a href="mailto:foohsinglong@gmail.com">kevin.long</a>
* @description Java获取系统软件安装列表,代码核心来自网上,主要通过Runtime实现,
* 用JNI也行,解决乱码问题
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextPane;
public class SystemSoftware {
private JFrame f = new JFrame("本系统已经安装的软件列表");
private JTextPane textPane = new JTextPane();
private MyTable myTable=new MyTable();
public static Charset charset = Charset.forName("GBK");
public SystemSoftware() {
f.setLocation(300, 200);
f.setSize(800,500);
JScrollPane jScrollPane = new JScrollPane(myTable.getTable());
f.add(jScrollPane);
f.setVisible(true);
f.setDefaultCloseOperation(f.EXIT_ON_CLOSE);
try {
check();
} catch (Exception e) {
e.printStackTrace();
}
}
private void check() throws Exception {
textPane.setText("您已经安装的软件:");
Runtime runtime = Runtime.getRuntime();
Process process = null;
Process process1 = null;
//64位
process = runtime.exec("cmd /c reg query HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\");
//32位
process1 = runtime.exec("cmd /c reg query HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\");
//HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall
BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream(),"GBK"));
BufferedReader in1 = new BufferedReader(new InputStreamReader(process1.getInputStream(),"GBK"));
String string = null;
String s3

本文介绍了一种使用Java代码获取Windows系统中已安装软件列表的方法。该方法利用Runtime执行CMD命令,通过注册表查询获取软件名称、版本等信息,并通过JNI解决乱码问题。
最低0.47元/天 解锁文章
1055

被折叠的 条评论
为什么被折叠?



