Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

modifying the registry key value

I have a registry path of the following

HKEY_LOCAL_MACHINE\SOFTWARE\COMPANY\COMPFOLDER 

inside COMPFOLDER, I have a string value called "Deno" whose value is 0. I wish to change its value to 1 by code whenever I execute the code. Can anyone help me?

like image 614
Harish Kumar Avatar asked Jan 11 '12 08:01

Harish Kumar


People also ask

Which command modify the value of a key in the registry editor?

Execute regedit to start Registry Editor. Anywhere you have command line access will work fine. See How to Open Registry Editor if you need help. On the left side of Registry Editor, locate the key you want to rename or the key that contains the value you want to change in some way.

What does editing the registry do?

The Windows Registry Editor (regedit) is a graphical tool in the Microsoft Windows operating system (OS) that enables authorized users to view the Windows registry and make changes.


2 Answers

It's been a while I did reg hacks, but something like this could work:

RegistryKey myKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Company\\Compfolder", true); if(myKey != null)    {    myKey.SetValue("Deno", "1", RegistryValueKind.String);    myKey.Close(); } 
like image 147
Jontatas Avatar answered Oct 09 '22 05:10

Jontatas


using (RegistryKey key = regKeyRoot.OpenSubKey(KeyName, true)) // Must dispose key or use "using" keyword {     if (key != null)  // Must check for null key     {         key.SetValue(attribute, value);     } } 
like image 41
electricalbah Avatar answered Oct 09 '22 03:10

electricalbah