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

x
?
Solved

Changing a registry value in C#

Posted on 2006-11-29
4
Medium Priority
?
250 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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
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…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

688 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