How to read a registry variable of type reg_binary? For example, the value of a variable of type reg_sz I read the code below. But when I try to access the reg_binary type, I get null.

public static void main(String[] args) { String value = com.sun.deploy.util.WinRegistry.getString(WinRegistry.HKEY_CURRENT_USER, "Control Panel\\Desktop", "TranscodedImageCache"); System.out.println(value); } 

    1 answer 1

    I can't tell you about WinRegistry, but when I needed to get into the registry, I did it through the Windows command "reg query". True, it does not know how to display only the value of the parameter, so you have to parse the output:

     Process p = Runtime.getRuntime() .exec("reg query \"HKCU\\Control Panel\\Desktop\" /v TranscodedImageCache"); BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream())); String line; while ((line = in.readLine()) != null) { line = line.trim(); if (line.startsWith("TranscodedImageCache")) { String value = line.split("\\s+")[2]; System.out.println(value); break; } }