RSS Forums RSS

vb.net 08 Reading data from multiple reg keys

Please support our VB.NET advertiser: DiscountASP.NET – 3 Months Free on VB.NET Web Hosting
Thread Solved
Reply
Posts: 44
Reputation: smelf1 is an unknown quantity at this point 
Solved Threads: 0
smelf1 smelf1 is offline Offline
Light Poster

vb.net 08 Reading data from multiple reg keys

  #1  
Jan 6th, 2009
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

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
AddThis Social Bookmark Button
Reply With Quote  
Posts: 1,867
Reputation: Ramy Mahrous has a spectacular aura about Ramy Mahrous has a spectacular aura about 
Solved Threads: 214
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Posting Virtuoso

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

  #2  
Jan 6th, 2009
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
  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 10:06 am.
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote  
Posts: 44
Reputation: smelf1 is an unknown quantity at this point 
Solved Threads: 0
smelf1 smelf1 is offline Offline
Light Poster

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

  #3  
Jan 6th, 2009
Originally Posted by RamyMahrous View Post
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
  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 10:17 am.
Reply With Quote  
Posts: 1,867
Reputation: Ramy Mahrous has a spectacular aura about Ramy Mahrous has a spectacular aura about 
Solved Threads: 214
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Posting Virtuoso

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

  #4  
Jan 6th, 2009
Put your key in array
Dim key As String(numberOfKeys)
sorry I've mistake in this instead 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
Reply With Quote  
Posts: 1,867
Reputation: Ramy Mahrous has a spectacular aura about Ramy Mahrous has a spectacular aura about 
Solved Threads: 214
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Posting Virtuoso

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

  #5  
Jan 6th, 2009
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
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote  
Posts: 44
Reputation: smelf1 is an unknown quantity at this point 
Solved Threads: 0
smelf1 smelf1 is offline Offline
Light Poster

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

  #6  
Jan 6th, 2009
Originally Posted by RamyMahrous View Post
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 10:56 am.
Reply With Quote  
Posts: 44
Reputation: smelf1 is an unknown quantity at this point 
Solved Threads: 0
smelf1 smelf1 is offline Offline
Light Poster

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

  #7  
Jan 7th, 2009
I found something similar in c#

( 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?
Reply With Quote  
Posts: 258
Reputation: rapture has a spectacular aura about rapture has a spectacular aura about 
Solved Threads: 36
rapture rapture is offline Offline
Posting Whiz in Training

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

  #8  
Jan 7th, 2009
I'm newer to vb.net so the others might change this a bit


     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
Reply With Quote  
Posts: 1,867
Reputation: Ramy Mahrous has a spectacular aura about Ramy Mahrous has a spectacular aura about 
Solved Threads: 214
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Posting Virtuoso

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

  #9  
Jan 7th, 2009
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
Reply With Quote  
Posts: 44
Reputation: smelf1 is an unknown quantity at this point 
Solved Threads: 0
smelf1 smelf1 is offline Offline
Light Poster

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

  #10  
Jan 7th, 2009
okay i got this now but it returns nothing

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
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Similar Threads
Other Threads in the VB.NET Forum
Views: 1193 | Replies: 22 | Currently Viewing: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 3:12 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC