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


Messages In This Thread
[TuToRiAl] The Registry + Visual Basic (Part 1) - by Resistance - 10-03-2010, 10:13 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  VB.Net Make a Real AntiVirus (AV) - Part 1 goranpilkic 27 29,985 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,444 01-15-2013, 09:30 PM
Last Post: Resistance
  [TuToRiAl] How to make Offline (No Internet) Captcha (Human Confirmation) [TuToRiAl] Resistance 24 12,531 08-30-2012, 10:14 PM
Last Post: Resistance
  [Visual Basic] FTP Uploader [Tutorial] Coding Support 6 3,010 08-12-2012, 12:36 AM
Last Post: Kenneth
  Visual Studio Bill Nye The Science Guy 1 1,030 03-19-2012, 09:08 AM
Last Post: BreShiE

Forum Jump:


Users browsing this thread: 5 Guest(s)