提交 e99ff903 authored 作者: yangli's avatar yangli

.

上级 818fb72c
...@@ -29,15 +29,20 @@ public class InstalledProgramCache { ...@@ -29,15 +29,20 @@ public class InstalledProgramCache {
@Scheduled(fixedDelay = 3000) @Scheduled(fixedDelay = 3000)
protected void loadProgramListJob() throws IOException { protected void loadProgramListJob() throws IOException {
List<Map<String, String>> programs = new ArrayList<>(); List<Map<String, String>> programs = new ArrayList<>();
Process process = Runtime.getRuntime() String[] regPaths = {
.exec("cmd /c reg query HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\"); "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\",
try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream(), "GBK"))) { "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\"
String key; };
while ((key = reader.readLine()) != null) { for (String regPath : regPaths) {
Map<String, String> info = queryProgramInfo(key); Process process = Runtime.getRuntime().exec("cmd /c reg query " + regPath);
if (info.containsKey("name")) programs.add(info); try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream(), "GBK"))) {
String key;
while ((key = reader.readLine()) != null) {
Map<String, String> info = queryProgramInfo(key);
if (info.containsKey("name")) programs.add(info);
}
process.destroy();
} }
process.destroy();
} }
programList = programs; programList = programs;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论