10-10-2010, 06:11 PM
(This post was last modified: 10-12-2010, 06:52 AM by Resistance.)
Hello everyone, your tutorial guru, legitwaste here...
Today we are going to learn how to edit and read a registry key, extremely simple, unless you want to make it complicated for yourself lol.
WARNING: You Must Be Running the Application as an Administrator if you are using Windows Vista/7, XP Users need to use this technique
only when accessing the LOCAL_MACHINE.
Now add 2 buttons and 2 textboxes to your form so that they look like this:
![[Image: 29dfpqq.png]](http://i56.tinypic.com/29dfpqq.png)
Now for the coding.
As usual we must import ms.win32
Next we will edit the code of "read a value" a.k.a. Button1.
We are trying to find and then edit the value of the string, Test. As you can see the value is "SupportForumsRocks".
![[Image: 2vvqbuh.png]](http://i54.tinypic.com/2vvqbuh.png)
Lets see if we can make it work.
It works!
![[Image: 2jf14b4.png]](http://i54.tinypic.com/2jf14b4.png)
Now for the second button a.k.a. Edit the value, in vb known as "set".
Now the results should be like this:
![[Image: 23sdp5l.png]](http://i51.tinypic.com/23sdp5l.png)
Then after setting the value to HFrox,
![[Image: 2ceop75.png]](http://i53.tinypic.com/2ceop75.png)
![[Image: rmv3hy.png]](http://i55.tinypic.com/rmv3hy.png)
And that is how you are able to read and edit the value of a registry key.
Today we are going to learn how to edit and read a registry key, extremely simple, unless you want to make it complicated for yourself lol.
WARNING: You Must Be Running the Application as an Administrator if you are using Windows Vista/7, XP Users need to use this technique
only when accessing the LOCAL_MACHINE.
Now add 2 buttons and 2 textboxes to your form so that they look like this:
![[Image: 29dfpqq.png]](http://i56.tinypic.com/29dfpqq.png)
Now for the coding.
As usual we must import ms.win32
Code:
Imports Microsoft.Win32
Public Class Form1
Next we will edit the code of "read a value" a.k.a. Button1.
We are trying to find and then edit the value of the string, Test. As you can see the value is "SupportForumsRocks".
![[Image: 2vvqbuh.png]](http://i54.tinypic.com/2vvqbuh.png)
Lets see if we can make it work.
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Text = Registry.GetValue("HKEY_CURRENT_USER\Environment\", "Testing", "")
End Sub
It works!
![[Image: 2jf14b4.png]](http://i54.tinypic.com/2jf14b4.png)
Now for the second button a.k.a. Edit the value, in vb known as "set".
Code:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Registry.SetValue("HKEY_CURRENT_USER\Environment\", "Testing", TextBox2.Text, RegistryValueKind.String)
End Sub
Now the results should be like this:
![[Image: 23sdp5l.png]](http://i51.tinypic.com/23sdp5l.png)
Then after setting the value to HFrox,
![[Image: 2ceop75.png]](http://i53.tinypic.com/2ceop75.png)
![[Image: rmv3hy.png]](http://i55.tinypic.com/rmv3hy.png)
And that is how you are able to read and edit the value of a registry key.
![[Image: t5BWm.png]](http://i.imgur.com/t5BWm.png)