mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-22 07:30:24 +00:00
Bump versions and rework registry query
This commit is contained in:
parent
3436d69d71
commit
c38472e870
6 changed files with 19 additions and 50 deletions
|
@ -1,5 +1,5 @@
|
|||
plugins {
|
||||
id 'org.jreleaser' version '1.2.0'
|
||||
id 'org.jreleaser' version '1.3.1'
|
||||
}
|
||||
|
||||
if(project == rootProject) {
|
||||
|
|
2
deps
2
deps
|
@ -1 +1 @@
|
|||
Subproject commit 23936c9a6a2ec35f0ca71266debb93d06144df9d
|
||||
Subproject commit d0578cfb68e7668423988fafa96659eaae219a0e
|
|
@ -24,6 +24,8 @@ dependencies {
|
|||
api group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: "2.13.0"
|
||||
api group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: "2.13.0"
|
||||
|
||||
compileOnly 'net.java.dev.jna:jna-jpms:5.12.1'
|
||||
compileOnly 'net.java.dev.jna:jna-platform-jpms:5.12.1'
|
||||
compileOnly group: 'org.kordamp.ikonli', name: 'ikonli-javafx', version: "12.2.0"
|
||||
compileOnly group: 'org.fxmisc.richtext', name: 'richtextfx', version: '0.10.9'
|
||||
compileOnly 'net.synedra:validatorfx:0.3.1'
|
||||
|
|
|
@ -1,60 +1,25 @@
|
|||
package io.xpipe.extension.util;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.StringWriter;
|
||||
import com.sun.jna.platform.win32.Advapi32Util;
|
||||
import com.sun.jna.platform.win32.WinReg;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class WindowsRegistry {
|
||||
|
||||
public static Optional<String> readRegistry(String location, String key) {
|
||||
try {
|
||||
Process process =
|
||||
Runtime.getRuntime().exec("reg query " + '"' + location + "\"" + (key != null ? " /v " + key : " /ve"));
|
||||
public static final int HKEY_CURRENT_USER = 0x80000001;
|
||||
public static final int HKEY_LOCAL_MACHINE = 0x80000002;
|
||||
|
||||
StreamReader reader = new StreamReader(process.getInputStream());
|
||||
reader.start();
|
||||
process.waitFor();
|
||||
reader.join();
|
||||
String output = reader.getResult();
|
||||
|
||||
// Output has the following format:
|
||||
// \n<Version information>\n\n<key>\t<registry type>\t<value>
|
||||
if (output.contains("\t")) {
|
||||
String[] parsed = output.split("\t");
|
||||
return Optional.of(parsed[parsed.length - 1]);
|
||||
}
|
||||
|
||||
if (output.contains(" ")) {
|
||||
String[] parsed = output.split(" ");
|
||||
return Optional.of(parsed[parsed.length - 1].substring(0, parsed[parsed.length - 1].length() - 4));
|
||||
}
|
||||
|
||||
return Optional.empty();
|
||||
} catch (Exception e) {
|
||||
return Optional.empty();
|
||||
}
|
||||
public static Optional<String> readString(int hkey, String key) {
|
||||
return readString(hkey,key, null);
|
||||
}
|
||||
|
||||
static class StreamReader extends Thread {
|
||||
private final InputStream is;
|
||||
private final StringWriter sw = new StringWriter();
|
||||
|
||||
public StreamReader(InputStream is) {
|
||||
this.is = is;
|
||||
public static Optional<String> readString(int hkey, String key, String valueName) {
|
||||
if (!Advapi32Util.registryValueExists(hkey == HKEY_LOCAL_MACHINE ? WinReg.HKEY_LOCAL_MACHINE : WinReg.HKEY_CURRENT_USER, key, valueName)) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
int c;
|
||||
while ((c = is.read()) != -1) sw.write(c);
|
||||
} catch (IOException e) {
|
||||
System.err.println(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public String getResult() {
|
||||
return sw.toString();
|
||||
}
|
||||
return Optional.ofNullable(Advapi32Util.registryGetStringValue(
|
||||
hkey == HKEY_LOCAL_MACHINE ? WinReg.HKEY_LOCAL_MACHINE : WinReg.HKEY_CURRENT_USER, key, valueName));
|
||||
}
|
||||
}
|
|
@ -18,6 +18,8 @@ open module io.xpipe.extension {
|
|||
requires io.xpipe.beacon;
|
||||
requires io.xpipe.api;
|
||||
requires com.fasterxml.jackson.databind;
|
||||
requires static com.sun.jna;
|
||||
requires static com.sun.jna.platform;
|
||||
requires static org.junit.jupiter.api;
|
||||
requires static org.apache.commons.lang3;
|
||||
requires static javafx.base;
|
||||
|
|
|
@ -18,7 +18,7 @@ jreleaser {
|
|||
|
||||
java {
|
||||
groupId = 'io.xpipe'
|
||||
version = '17'
|
||||
version = '19'
|
||||
multiProject = true
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue