Solved

check registry using c#?

Posted on 2012-03-19
4
474 Views
Last Modified: 2012-03-20
Hi,

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)?
0
Comment
Question by:dkim18
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 16

Assisted Solution

by:Easwaran Paramasivam
Easwaran Paramasivam earned 250 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
0
 
LVL 9

Accepted Solution

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

Open in new window


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

Assisted Solution

by:BuggyCoder
BuggyCoder earned 100 total points
ID: 37737669
0
 

Author Comment

by:dkim18
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?


http://www.experts-exchange.com/Programming/Languages/C_Sharp/Q_27640152.html
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

617 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