| | |
vb.net 08 Reading data from multiple reg keys
Please support our VB.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
Thread Solved
![]() |
•
•
Join Date: Mar 2008
Posts: 44
Reputation:
Solved Threads: 0
Hi,
In the reg key below there can be 50 different keys, how can i read through each one and get its display name and then show those display names in a lsitbox or combo box.
hkey_local_machine\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
I am using the code below to get the data in that single key but how do i get all data in display name in each of the multiple keys located in the key folder above
In the reg key below there can be 50 different keys, how can i read through each one and get its display name and then show those display names in a lsitbox or combo box.
hkey_local_machine\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
I am using the code below to get the data in that single key but how do i get all data in display name in each of the multiple keys located in the key folder above
VB.NET Syntax (Toggle Plain Text)
Imports System Imports Microsoft.Win32 Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim myCPUDescription As String = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0", "ProcessorNameString", "No CPU Found").ToString.Trim ComboBox1.Items.Add(myCPUDescription) end sub
Put your key in array
Your array may be 2D to maintain the property of keys
Dim key As String(numberOfKeys) then loop and once you get value put it into ComboBox or any control you present data into vb.net Syntax (Toggle Plain Text)
Dim registrykeys(5) As String 'fill your keys For Each key As String In registrykeys ComboBox1.Items.Add(My.Computer.Registry.GetValue(key, "property", "default")) Next
Last edited by Ramy Mahrous; Jan 6th, 2009 at 11:06 am.
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
•
•
Join Date: Mar 2008
Posts: 44
Reputation:
Solved Threads: 0
•
•
•
•
Put your key in array
Dim key As String(numberOfKeys)then loop and once you get value put it into ComboBox or any control you present data into
Your array may be 2D to maintain the property of keysvb.net Syntax (Toggle Plain Text)
Dim registrykeys(5) As String 'fill your keys For Each key As String In registrykeys ComboBox1.Items.Add(My.Computer.Registry.GetValue(key, "property", "default")) Next
I am new to vb.net so bear with me : ).
Now in that part of the reg i am looking the keys can be different depending on the installed programs.
So i cannot just add the exact key to read.
Last edited by smelf1; Jan 6th, 2009 at 11:17 am.
•
•
•
•
Put your key in array
Dim key As String(numberOfKeys)
Dim Keys(numberOfKeys) As string BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Give me the keys you want to get and it's properties in that way
Exmaple
Key: HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0
Property: ProcessorStringName
Don't worry, just show me you want to learn
Exmaple
Key: HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0
Property: ProcessorStringName
Don't worry, just show me you want to learn
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
•
•
Join Date: Mar 2008
Posts: 44
Reputation:
Solved Threads: 0
•
•
•
•
Give me the keys you want to get and it's properties in that way
Exmaple
Key: HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0
Property: ProcessorStringName
Don't worry, just show me you want to learn
The keys are all located in hkey_local_machine\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall its where the registry stores all the installed programs.
I want to open each key it finds under hkey_local_machine\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall and display what is in DisplayName in a combobox or text box.
So on my pc i have a program called casecatalyst and its key is under
hkey_local_machine\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\caseCatalyst4 and in here i am after DisplayName which is Case Catalyst.
So if i only have casecatalyst and say adobe installed the only keys in hkey_local_machine\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall will be \casecatalyst4 and \adobe.
So i assume i need to be able to open uninstall\ read each key and populate their display names into a combo or text box.
See i need to find all currently installed programs on a pc
Last edited by smelf1; Jan 6th, 2009 at 11:56 am.
•
•
Join Date: Mar 2008
Posts: 44
Reputation:
Solved Threads: 0
I found something similar in c#
can this be changed into .net?
VB.NET Syntax (Toggle Plain Text)
( static void GetInstalled() { string uninstallKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"; using (RegistryKey rk = Registry.LocalMachine.OpenSubKey(uninstallKey)) { foreach (string skName in rk.GetSubKeyNames()) { using (RegistryKey sk = rk.OpenSubKey(skName)) { Console.WriteLine(sk.GetValue("DisplayName")); } } } })
can this be changed into .net?
•
•
Join Date: Jul 2007
Posts: 276
Reputation:
Solved Threads: 37
I'm newer to vb.net so the others might change this a bit
VB.NET Syntax (Toggle Plain Text)
Private Shared Sub GetInstalled() Dim uninstallKey As String = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" Using rk As RegistryKey = Registry.LocalMachine.OpenSubKey(uninstallKey) For Each skName As String In rk.GetSubKeyNames() Using sk As RegistryKey = rk.OpenSubKey(skName) Console.WriteLine(sk.GetValue("DisplayName")) End Using Next End Using End Sub
Yes, It could be, understand the C# code, and if you fail to convert any line of code to VB.NET, drop a reply soon.
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
•
•
Join Date: Mar 2008
Posts: 44
Reputation:
Solved Threads: 0
okay i got this now but it returns nothing
VB.NET Syntax (Toggle Plain Text)
Dim uninstallKey As String = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" Dim rk As RegistryKey rk = Registry.LocalMachine.OpenSubKey(uninstallKey) For Each key As String In rk.GetSubKeyNames() Using sk As RegistryKey = rk.OpenSubKey(key) Console.WriteLine(sk.GetValue("DisplayName")) End Using Next End Sub
![]() |
Similar Threads
- Help with automatic update problem and more (Viruses, Spyware and other Nasties)
Other Threads in the VB.NET Forum
- Previous Thread: Problem in Removing Node from XML using Vb.net
- Next Thread: retaining graphics
| Thread Tools | Search this Thread |
.net .net2008 2005 2008 access account add application array basic beginner browser button buttons center check click code combo cpu crystalreport cuesent database datagrid datagridview date datetimepicker designer dissertation dissertations dissertationtopic dropdownlist excel exists fade file-dialog filter forms ftp generatetags html images input insert intel listview mobile module monitor mysql net number open output panel passingparameters picturebox picturebox2 port print printing printpreview problem regex reuse right-to-left searchvb.net select settings shutdown socket sqldatbase sqlserver storedprocedure survey tcp temperature textbox timespan transparency trim txttoxmlconverter user usercontol vb vb.net vb.netformclosing()eventpictureboxmessagebox vb2008 vbnet vista visual visualbasic.net visualstudio.net visualstudio2008 web winforms wpf wrapingcode xml year






