How to access Registry in VB.NET?
-
Have a look at the article "Registry handling with .NET" by S Nishant in this site (www.codeproject.com/dotnet/csregistry01.asp). The VB.NET equivalent is virtually identical. Imports Microsoft.Win32.Registry Imports Microsoft.Win32.RegistryKey Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim rKey As Microsoft.Win32.RegistryKey Dim rKey1 As Microsoft.Win32.RegistryKey rKey = Microsoft.Win32.Registry.LocalMachine rKey1 = rKey.OpenSubKey("SOFTWARE\Microsoft\Windows NT\CurrentVersion") ListBox1.Items.Add("RegisteredOwner :- " + rKey1.GetValue("RegisteredOwner")) ListBox1.Items.Add("RegisteredOrganization :- " + rKey1.GetValue("RegisteredOrganization")) ListBox1.Items.Add("ProductName :- " + rKey1.GetValue("ProductName")) ListBox1.Items.Add("CSDVersion :- " + rKey1.GetValue("CSDVersion")) ListBox1.Items.Add("SystemRoot :- " + rKey1.GetValue("SystemRoot")) rKey1.Close() End Sub HTH Andy
-
Have a look at the article "Registry handling with .NET" by S Nishant in this site (www.codeproject.com/dotnet/csregistry01.asp). The VB.NET equivalent is virtually identical. Imports Microsoft.Win32.Registry Imports Microsoft.Win32.RegistryKey Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim rKey As Microsoft.Win32.RegistryKey Dim rKey1 As Microsoft.Win32.RegistryKey rKey = Microsoft.Win32.Registry.LocalMachine rKey1 = rKey.OpenSubKey("SOFTWARE\Microsoft\Windows NT\CurrentVersion") ListBox1.Items.Add("RegisteredOwner :- " + rKey1.GetValue("RegisteredOwner")) ListBox1.Items.Add("RegisteredOrganization :- " + rKey1.GetValue("RegisteredOrganization")) ListBox1.Items.Add("ProductName :- " + rKey1.GetValue("ProductName")) ListBox1.Items.Add("CSDVersion :- " + rKey1.GetValue("CSDVersion")) ListBox1.Items.Add("SystemRoot :- " + rKey1.GetValue("SystemRoot")) rKey1.Close() End Sub HTH Andy
Heya - I also had a bit of trouble with the registry. I can modify it easy enough but I can't get it to refresh without restarting the computer. Is there some way to force Windows to reload the registry without restarting? :confused: Thanks Nic R_
------------------------------------------ I beat the internet - the end guy is hard.
_
-
Heya - I also had a bit of trouble with the registry. I can modify it easy enough but I can't get it to refresh without restarting the computer. Is there some way to force Windows to reload the registry without restarting? :confused: Thanks Nic R_
------------------------------------------ I beat the internet - the end guy is hard.
_
Some of the system settings are read from the registry ONLY during windows logon/boot-up. That's why some apps force you to restart Windows after installation. Nish
Author of the romantic comedy Summer Love and Some more Cricket [New Win] Review by Shog9 Click here for review[NW]