Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6022127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:48:51+00:00 2026-05-23T03:48:51+00:00

Possible Duplicate: read/write to Windows Registry using Java I want to read the registry

  • 0

Possible Duplicate:
read/write to Windows Registry using Java

I want to read the registry value of the path HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\WINDOWS\CurrentVersion\Uninstall\{2FC099BD-AC9B-33EB-809C-D332E1B27C40}.

Can you please help me with the code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T03:48:52+00:00Added an answer on May 23, 2026 at 3:48 am

    This shows how to read the registry, but could be extended to write operations: How to read the Windows Registry

    import java.io.*;
    
    public class RegQuery {
    
      private static final String REGQUERY_UTIL = "reg query ";
      private static final String REGSTR_TOKEN = "REG_SZ";
      private static final String REGDWORD_TOKEN = "REG_DWORD";
    
      private static final String PERSONAL_FOLDER_CMD = REGQUERY_UTIL +
        "\"HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\"
         + "Explorer\\Shell Folders\" /v Personal";
      private static final String CPU_SPEED_CMD = REGQUERY_UTIL +
        "\"HKLM\\HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0\""
         + " /v ~MHz";
      private static final String CPU_NAME_CMD = REGQUERY_UTIL +
       "\"HKLM\\HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0\""
         + " /v ProcessorNameString";
    
      public static String getCurrentUserPersonalFolderPath() {
        try {
          Process process = Runtime.getRuntime().exec(PERSONAL_FOLDER_CMD);
          StreamReader reader = new StreamReader(process.getInputStream());
    
          reader.start();
          process.waitFor();
          reader.join();
    
          String result = reader.getResult();
          int p = result.indexOf(REGSTR_TOKEN);
    
          if (p == -1)
             return null;
    
          return result.substring(p + REGSTR_TOKEN.length()).trim();
        }
        catch (Exception e) {
          return null;
        }
      }
    
      public static String getCPUSpeed() {
        try {
          Process process = Runtime.getRuntime().exec(CPU_SPEED_CMD);
          StreamReader reader = new StreamReader(process.getInputStream());
    
          reader.start();
          process.waitFor();
          reader.join();
    
          String result = reader.getResult();
          int p = result.indexOf(REGDWORD_TOKEN);
    
          if (p == -1)
             return null;
    
          // CPU speed in Mhz (minus 1) in HEX notation, convert it to DEC
          String temp = result.substring(p + REGDWORD_TOKEN.length()).trim();
          return Integer.toString
              ((Integer.parseInt(temp.substring("0x".length()), 16) + 1));
        }
        catch (Exception e) {
          return null;
        }
      }
    
      public static String getCPUName() {
        try {
          Process process = Runtime.getRuntime().exec(CPU_NAME_CMD);
          StreamReader reader = new StreamReader(process.getInputStream());
    
          reader.start();
          process.waitFor();
          reader.join();
    
          String result = reader.getResult();
          int p = result.indexOf(REGSTR_TOKEN);
    
          if (p == -1)
             return null;
    
          return result.substring(p + REGSTR_TOKEN.length()).trim();
        }
        catch (Exception e) {
          return null;
        }
      }
    
      static class StreamReader extends Thread {
        private InputStream is;
        private StringWriter sw;
    
        StreamReader(InputStream is) {
          this.is = is;
          sw = new StringWriter();
        }
    
        public void run() {
          try {
            int c;
            while ((c = is.read()) != -1)
              sw.write(c);
            }
            catch (IOException e) { ; }
          }
    
        String getResult() {
          return sw.toString();
        }
      }
    
      public static void main(String s[]) {
        System.out.println("Personal directory : "
           + getCurrentUserPersonalFolderPath());
        System.out.println("CPU Name : " + getCPUName());
        System.out.println("CPU Speed : " + getCPUSpeed() + " Mhz");
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How do you send email from a Java app using Gmail? How
Possible Duplicate: How to properly clean up Excel interop objects in C# I've read
Possible Duplicate: Garbage Collection in C++ — why? Hi, I read few articles about
Possible Duplicate: Pointer to local variable I've read a lot of other topics on
Possible Duplicate: How can I declare a thousand separator in read.csv? I actually have
Possible Duplicate: Null object in javascript Hi, I've read this thread about null in
Possible Duplicate: What can you use Python generator functions for? I tried to read
Possible Duplicate: Explain JavaScript's encapsulated anonymous function syntax I have just read a javascript
Possible Duplicate: Reading through file using ifstream I'm trying to find a way to
Possible Duplicate: How to write program during compiling? I found this problem on a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.