Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[TuToRiAl] The Registry + Visual Basic (Part 1)
#1
Hello everyone. This will be a simple tutorial on how to use common registry commands that can bond in to your application.

We will be going over the following:

1) Adding a Registry Key to the Registry
2) Removing a Registry Key
-----------------------------------------------

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.

1) Adding a Registry Key

First things first, add to the very top of the code form, Imports Microsoft.Win32.

Code:
Imports Microsoft.Win32
Public Class Form1

Now for the Button1 Code:
Below is a condensed version for the code or CURRENT_USER Directory in the Registry.
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Registry.CurrentUser.SetValue("RandomKey", "My Reg Key", "Worked", "RegistryValueKind.DWord") 'The RandomKey is the actual key that stores multiple registry files.  
MsgBox("Registry Key created successfully created.",64,"Registry Key Creator") 'The name of the key is My Reg Key and the value is Worked.
End Sub

Now here is something you NEVER knew about. The value type, is it DWord? QWord? Binary? String? MultiString? ExpandString or even Unknown?

Below is a code of writing a key into a specific place in the registry.

Code:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            Registry.SetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "RandomKey", "0", RegistryValueKind.DWord")
    End Sub

2) Removing a Registry Key

Now we will remove the registry key we created in the first place.

Code:
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
         Registry.CurrentUser.DeleteValue("RandomKey", "My Reg Key", "Worked", "RegistryValueKind.DWord")
MsgBox("Registry key value has been deleted", 16,"Registry Key Creator")
End Sub

Now if we had taken off the Worked and My Reg Key + RegistryValueKind.DWord and it wouldv'e looked like this:
Code:
Registry.CurrentUser.DeleteValue("RandomKey") ' Thus deleting the actual key.

THE END.

I hope this might have helped you guys... somewhat Big Grin
[Image: t5BWm.png]
Reply
#2
Great tutorial pal. Thanks for sharing this with us and ill try this out asap. The thread is made nicely and you have done a very good job with it. Nice work pal
[Image: banner.gif]
Reply
#3
Awesome tutorial, This is probably the best / easiest way to edit the redistry with vb.net
Reply
#4
I will add one more, editing the value and reading the regkeys value in a snap, great for getting certain information on a specific program, software or even your computer.
[Image: t5BWm.png]
Reply
#5
In any Registry Tutorial, you can't forget to post how to make BACKUPS. It's the most important thing anyone needs to know if you make any changes at all period.

Extracting a key and saving it for later.
Reply
#6
Well, I was creating a Test Key, but thank you captain for telling me the ship is sinking atm. LOL
[Image: t5BWm.png]
Reply
#7
(10-03-2010, 06:35 PM)L3g1tWa5te Wrote: Well, I was creating a Test Key, but thank you captain for telling me the ship is sinking atm. LOL

Like I said, i'm not here to bash all your good tutorials Smile they are good contributions, i'm just making notes of things that are also important to your tutorials lol.

Even if you create your own key, there can be conflicts
Reply
#8
(10-03-2010, 06:39 PM)Infinity Wrote: Like I said, i'm not here to bash all your good tutorials Smile they are good contributions, i'm just making notes of things that are also important to your tutorials lol.

Even if you create your own key, there can be conflicts

Rarely, if your computer is thinking 1+1 = 3 then possibly... yes. Roflmao

But I like your input its helpful... I have so many tutorials to post but i'm not going to post them all in one shot. People think its spam and it is so... 2 a day out of one hundred and increasing lol.
[Image: t5BWm.png]
Reply
#9
Thank you for the share. Every little helps.
[Image: s1.jpg]
Reply
#10
This is definitley a good tut for me very useful
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  VB.Net Make a Real AntiVirus (AV) - Part 1 goranpilkic 27 29,555 08-25-2014, 12:43 AM
Last Post: dark_move
  How To make an advanced Operating System in Visual Basic 2010 ? Mohamed Samir 9 12,258 01-15-2013, 09:30 PM
Last Post: Resistance
  [TuToRiAl] How to make Offline (No Internet) Captcha (Human Confirmation) [TuToRiAl] Resistance 24 12,244 08-30-2012, 10:14 PM
Last Post: Resistance
  [Visual Basic] FTP Uploader [Tutorial] Coding Support 6 2,963 08-12-2012, 12:36 AM
Last Post: Kenneth
  Visual Studio Bill Nye The Science Guy 1 995 03-19-2012, 09:08 AM
Last Post: BreShiE

Forum Jump:


Users browsing this thread: 1 Guest(s)