google search

Tuesday, July 7, 2009

How to add registry keys using visual basic

Ok, so just a little notice - this is for information purposes only - I am in no way responsible for any malicious or illegal uses.

This code works great for Visual Studio - It was written for Visual Basic language

'Before the "Public Class Form" one needs to type
Imports Microsoft.Win32

'imports the neccessary program within windows to add or edit the registry

' Then delcare the variables -
Dim KNAME, KVAL, VALNAME As String

' KNAME used as key name,
' KVAL used as key value
'VALNAME used as the name of the value within the registry

KNAME = "HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\RUN"
' This is the location within Windows XP to get a program to run everytime your computer starts

KVAL = "C:\yourpath\yourprogram.exe"
'This is the location of the program you want to run

'this is the name of the program as it appears within MSCONFIG or the registry
VALNAME = "yourprogram.exe"

'This sets the value of that registry key, if it does not exist, it will be created
Registry.SetValue(KNAME, VALNAME, KVAL)