Use of RegistryKeys in VB.NET
The RegistryKeys are the units of the hierarchical data storage in system registry.
The RegistryKeys are the units of the hierarchical data storage in system registry. Each key may have subkeys. Thay are similar to folders - in addition to values, each key can contain subkeys, which may contain further subkeys, and so on. Values associated with key can be edited, deleted or new values can be created related with that key. Each subkey has a mandatory name which is a non-empty string that cannot contain any backslash or null character, and whose letter case is insignificant.
Properties of RegistryKey are :
- Name
- SubKeyCount
- ValueCount
And the major methods are :
- CreateSubKey
- OpenSubKey
- GetSubKeyNames
- GetValue
- SetValue
Example
Imports System
Imports Microsoft.Win32
Imports System.Diagnostics
Imports System.Windows.Forms
Public Class keyvalues
Public Shared Sub Main()
Dim machine As RegistryKey
Dim config As RegistryKey
Dim details As RegistryKey
Dim system As RegistryKey
Dim cpu As RegistryKey
Dim information As RegistryKey
machine = Registry.LocalMachine
config = machine.OpenSubKey("HARDWARE")
details = config.OpenSubKey("DESCRIPTION")
system = details.OpenSubKey("SYSTEM")
cpu = system.OpenSubKey("CentralProcessor")
information = cpu.OpenSubKey("0")
Console.WriteLine(information.GetValue("VendorIdentifier"))
Console.WriteLine(information.GetValue("ProcessorNameString"))
Console.WriteLine(information.GetValue("Identifier"))
Console.WriteLine(information.GetValue("~Mhz") & "MHz")
Console.ReadLine()
End Sub
End Class
Output