Solved

Changing a registry value in C#

Posted on 2006-11-29
4
247 Views
Last Modified: 2010-04-16
I want to change the value of a registry key from 0x00000003 to 0x0000000. Here is the code I wrote to do it that doesnt work because rk is always null for some reason, I don't get it.

  RegistryKey rk = Registry.CurrentUser.OpenSubKey(@"My Computer\HKEY_CURRENT_USER\Software\Microsoft\Visio\Addins\mass.Connect");
           if (rk != null)
           {
               rk.SetValue("LoadBehavior", 0);
               rk.Close();
           }

Whats wrong here?
0
Comment
Question by:npl77
[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
  • 2
  • 2
4 Comments
 
LVL 14

Accepted Solution

by:
existenz2 earned 500 total points
ID: 18041014
It should be:

RegistryKey rk = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Visio\Addins\mass.Connect");
           if (rk != null)
           {
               rk.SetValue("LoadBehavior", 0);
               rk.Close();
           }


0
 

Author Comment

by:npl77
ID: 18041091
now it says i cant write to registry key. How I change that?
0
 

Author Comment

by:npl77
ID: 18041097
UnAuthorizedAccessException
0
 
LVL 14

Expert Comment

by:existenz2
ID: 18041110
You most likely don't have the rights to write to the registry. Is that correct?

Else give this a try:
RegistryKey rk = Registry.CurrentUser.OpenSubKey(@"HKEY_CURRENT_USER\Software\Microsoft\Visio\Addins\mass.Connect");

But that most likely won't work and it prolly is a registry security issue.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Code works but breaks when I add one section 4 35
Convert Silverlight ERP To Angularjs,HTML5 3 107
c#  FTP ftpwebrequest URI invalid 6 47
Load XML element 3 43
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

734 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