Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

check registry using c#?

Posted on 2012-03-19
4
Medium Priority
?
478 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 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
0
 
LVL 9

Accepted Solution

by:
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");
                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 400 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

RHCE - Red Hat OpenStack Prep Course

This course will provide in-depth training so that students who currently hold the EX200 & EX210 certifications can sit for the EX310 exam. Students will learn how to deploy & manage a full Red Hat environment with Ceph block storage, & integrate Ceph into other OpenStack service

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
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…

715 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