You are viewing our Forum Archives. To view or take place in current topics click here.
VB - Registry Tutorial
Posted:
VB - Registry TutorialPosted:
Status: Offline
Joined: Jan 10, 201410Year Member
Posts: 80
Reputation Power: 3
Status: Offline
Joined: Jan 10, 201410Year Member
Posts: 80
Reputation Power: 3
Quite a few people have recently asked me how to save data to the computers Registry so i thought i would write a basic tutorial on how to do it.
How to Create a Registry Key
When creating a registry key use the CreateSubKey method. This method is used to specify the folder where our Value will be located
Example:
My.Computer.Registry.CurrentUser.CreateSubKey("AppName\Coins")
Now to set the value of the Registry Key
First create an integer at the top of your code:
Private Coins = 100
Now lets create the value and save the number of coins we have:
My.Computer.Registry.SetValue("HKEY_CURRENT_USER\AppName\Coins", "Coins", Coins)
The code above sets the value of our Registry Key to how many coins the user has and it saves it under "HKEY_CURRENT_USER\AppName\Coins"
How to retrieve the value of our Registry Key
To get our value we will be using the GetValue method:
Dim readCoins = My.Computer.Registry.GetValue(
"HKEY_CURRENT_USER\AppName\Coins", "Coins", Nothing)
This was a very basic tutorial on getting and setting values from the Registry, if you have any questions pm me or leave a comment
You are viewing our Forum Archives. To view or take place in current topics click here.