Working with registry
Registry, to some, sounds like a big scary monster that'll f*ck your computer up and make you its b*tch. Not true, it is mostly used for settings and device info, I'm sure if you delete something, it'll pop back up sooner or later... but same can't be said for everything in the registry.
Before any of this, your program will need administration rights, so you'll need to edit the manifest, to do so, go to your project properties, click 'View Windows Settings', and change <requestExecutionLevel> to "requireAdministrator".
Registry is great for finding out computer information, such as Processor, Motherboard, GPU, Current Network name, Playback & Recording device name, and is also great for adding unfindable settings, without using an ini file (which can be a pain, trust me), using the following code
this creates a key, but the values are not automatically added, so you can add one using
You can rename values, but it can be hard to do.
You can also delete keys, but I'm not gonna scratch that surface with a 30 foot pole.
Does a key exist? You can do that too.
The code added Is Nothing, but you can remove that to swap the does not exist and exists code around if you find it easier.
Do you want to save settings of a program? Don't want them to save settings? Does your program cost 4000 dollars? *Cough* Microsoft *Cough* Well, with registry, you can do that! but hide it well... Let's hide it in... say... Internet Explorer, nobody ever looks through there...
This is just scratching the surface of registry, I'm sure you can do much much more with registry than this.
Before any of this, your program will need administration rights, so you'll need to edit the manifest, to do so, go to your project properties, click 'View Windows Settings', and change <requestExecutionLevel> to "requireAdministrator".
Registry is great for finding out computer information, such as Processor, Motherboard, GPU, Current Network name, Playback & Recording device name, and is also great for adding unfindable settings, without using an ini file (which can be a pain, trust me), using the following code
Code:
My.Computer.Registry.CurrentUser.CreateSubKey("KeyNameHere")
Code:
My.Computer.Registry.SetValue("HKEY_CURRENT_USER\KeyNameHere", "NameOfValue", "Value")
Code:
Dim TestKey = My.Computer.Registry.CurrentUser.OpenSubKey("KeyNameHere", True)
TestKey.SetValue("NameOfValue", "NewValue")
TestKey.Close()
Does a key exist? You can do that too.
Code:
If My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\KeyNameHere", "NewValue", Nothing) Is Nothing Then
'It does not exist.
Else
'It Exists
End If
Do you want to save settings of a program? Don't want them to save settings? Does your program cost 4000 dollars? *Cough* Microsoft *Cough* Well, with registry, you can do that! but hide it well... Let's hide it in... say... Internet Explorer, nobody ever looks through there...
Code:
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer", "IsPremium", "True")