943,584 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Marked Solved
  • Views: 3157
  • VB.NET RSS
You are currently viewing page 1 of this multi-page discussion thread
Jan 6th, 2009
0

vb.net 08 Reading data from multiple reg keys

Expand Post »
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

VB.NET Syntax (Toggle Plain Text)
  1. Imports System
  2. Imports Microsoft.Win32
  3.  
  4. Public Class Form1
  5. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  6. Dim myCPUDescription As String = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0", "ProcessorNameString", "No CPU Found").ToString.Trim
  7.  
  8. ComboBox1.Items.Add(myCPUDescription)
  9.  
  10. end sub
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
smelf1 is offline Offline
44 posts
since Mar 2008
Jan 6th, 2009
0

Re: vb.net 08 Reading data from multiple reg keys

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
vb.net Syntax (Toggle Plain Text)
  1. Dim registrykeys(5) As String
  2. 'fill your keys
  3. For Each key As String In registrykeys
  4. ComboBox1.Items.Add(My.Computer.Registry.GetValue(key, "property", "default"))
  5. Next
Your array may be 2D to maintain the property of keys
Last edited by Ramy Mahrous; Jan 6th, 2009 at 11:06 am.
Featured Poster
Reputation Points: 480
Solved Threads: 276
Postaholic
Ramy Mahrous is offline Offline
2,189 posts
since Aug 2006
Jan 6th, 2009
0

Re: vb.net 08 Reading data from multiple reg keys

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
vb.net Syntax (Toggle Plain Text)
  1. Dim registrykeys(5) As String
  2. 'fill your keys
  3. For Each key As String In registrykeys
  4. ComboBox1.Items.Add(My.Computer.Registry.GetValue(key, "property", "default"))
  5. Next
Your array may be 2D to maintain the property of keys
Hi thanks for the reply.

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.
Reputation Points: 10
Solved Threads: 0
Light Poster
smelf1 is offline Offline
44 posts
since Mar 2008
Jan 6th, 2009
0

Re: vb.net 08 Reading data from multiple reg keys

Quote ...
Put your key in array
Dim key As String(numberOfKeys)
sorry I've mistake in this instead Dim Keys(numberOfKeys) As string
Featured Poster
Reputation Points: 480
Solved Threads: 276
Postaholic
Ramy Mahrous is offline Offline
2,189 posts
since Aug 2006
Jan 6th, 2009
0

Re: vb.net 08 Reading data from multiple reg keys

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
Featured Poster
Reputation Points: 480
Solved Threads: 276
Postaholic
Ramy Mahrous is offline Offline
2,189 posts
since Aug 2006
Jan 6th, 2009
0

Re: vb.net 08 Reading data from multiple reg keys

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
No probs thanks,

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.
Reputation Points: 10
Solved Threads: 0
Light Poster
smelf1 is offline Offline
44 posts
since Mar 2008
Jan 7th, 2009
0

Re: vb.net 08 Reading data from multiple reg keys

I found something similar in c#

VB.NET Syntax (Toggle Plain Text)
  1. ( static void GetInstalled()
  2. {
  3. string uninstallKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
  4. using (RegistryKey rk = Registry.LocalMachine.OpenSubKey(uninstallKey))
  5. {
  6. foreach (string skName in rk.GetSubKeyNames())
  7. {
  8. using (RegistryKey sk = rk.OpenSubKey(skName))
  9. {
  10. Console.WriteLine(sk.GetValue("DisplayName"));
  11. }
  12. }
  13. }
  14. })

can this be changed into .net?
Reputation Points: 10
Solved Threads: 0
Light Poster
smelf1 is offline Offline
44 posts
since Mar 2008
Jan 7th, 2009
1

Re: vb.net 08 Reading data from multiple reg keys

I'm newer to vb.net so the others might change this a bit

VB.NET Syntax (Toggle Plain Text)
  1.  
  2.  
  3. Private Shared Sub GetInstalled()
  4. Dim uninstallKey As String = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
  5. Using rk As RegistryKey = Registry.LocalMachine.OpenSubKey(uninstallKey)
  6. For Each skName As String In rk.GetSubKeyNames()
  7. Using sk As RegistryKey = rk.OpenSubKey(skName)
  8. Console.WriteLine(sk.GetValue("DisplayName"))
  9. End Using
  10. Next
  11. End Using
  12. End Sub
Reputation Points: 155
Solved Threads: 41
Posting Whiz in Training
rapture is offline Offline
294 posts
since Jul 2007
Jan 7th, 2009
0

Re: vb.net 08 Reading data from multiple reg keys

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.
Featured Poster
Reputation Points: 480
Solved Threads: 276
Postaholic
Ramy Mahrous is offline Offline
2,189 posts
since Aug 2006
Jan 7th, 2009
0

Re: vb.net 08 Reading data from multiple reg keys

okay i got this now but it returns nothing

VB.NET Syntax (Toggle Plain Text)
  1. Dim uninstallKey As String = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
  2. Dim rk As RegistryKey
  3. rk = Registry.LocalMachine.OpenSubKey(uninstallKey)
  4. For Each key As String In rk.GetSubKeyNames()
  5. Using sk As RegistryKey = rk.OpenSubKey(key)
  6. Console.WriteLine(sk.GetValue("DisplayName"))
  7. End Using
  8. Next
  9. End Sub
Reputation Points: 10
Solved Threads: 0
Light Poster
smelf1 is offline Offline
44 posts
since Mar 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Problem in Removing Node from XML using Vb.net
Next Thread in VB.NET Forum Timeline: retaining graphics





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC