check registry using c#?

Posted on 2012-03-19
Medium Priority
Last Modified: 2012-03-20

I have a c# desktop application using WPF.

I need to check the registry from the application.
I would like to check if there is a certain registry entry at the specifica location.
1) How do I do that? Can you show me an example and guide me to a link?
2) does the application require the admin previlege to run this code (checking the registry)?
Question by:dkim18
LVL 16

Assisted Solution

by:Easwaran Paramasivam
Easwaran Paramasivam earned 1000 total points
ID: 37737531
Yes. You need Admin rights to read register.

RegistryKey registerkey = Registry.LocalMachine.OpenSubKey(RegisterKey);

Open in new window

Above code could be used to read register key.

Please do refer http://www.c-sharpcorner.com/UploadFile/mahesh/WorkingwithWindowsRegistry11282005045112AM/WorkingwithWindowsRegistry.aspx

Accepted Solution

sachinpatil10d earned 600 total points
ID: 37737558
Try this
        void writeRegKey(string key)
            RegistryKey registry = Registry.LocalMachine.CreateSubKey("SOFTWARE\\" + key);
            if (registry != null)
                registry.SetValue("myValue", "myReturnValue");
        string readRegKey(string key)
            string myRegString = "";
            RegistryKey registry = Registry.LocalMachine.CreateSubKey("SOFTWARE\\" + key);
            if (registry != null)
                myRegString = registry.GetValue("myValue").ToString();
            return myRegString;

Open in new window

you will definitely need administrative privileges to  read/ write registery.
LVL 20

Assisted Solution

BuggyCoder earned 400 total points
ID: 37737669

Author Comment

ID: 37742498
Can you clarify your answer on needing the admin right to read the registry?
I posted another question and they are saying you don't need the admin permission just to read the registry.

Did you guys mean you need the admin permission to write?


Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

SingleRun is a tool that ensures that only one instance of an application is started, running it again brings the application to focus.
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Watch the video to learn how one can deal with PST file corruption issue with an outstanding Kernel for Outlook PST Repair Tool easily. Using this tool, non-technical users can swiftly perform the repair process to restore their essential data witho…

600 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question