vb.net 08 Reading data from multiple reg keys

Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

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

 
0
  #11
Jan 7th, 2009
C# IS .net. It's just a C style usage of it.
  1. Public Function GetInstalled()
  2. Dim uninstallKey As String
  3. Dim rk As RegistryKey
  4. Dim sk As RegistryKey
  5. Dim skName As String
  6. Dim sublist As New ArrayList
  7.  
  8. uninstallKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
  9.  
  10. rk = Registry.LocalMachine.OpenSubKey(uninstallKey, True)
  11.  
  12. For Each skName In rk.GetSubKeyNames()
  13. sk = rk.OpenSubKey(skName)
  14. sublist.Add(sk.GetValue("DisplayName"))
  15. Next skName
  16.  
  17. Return sublist
  18. End Function


EDIT: Sorry, Didn't Refresh The Page Before Posting...
Last edited by Comatose; Jan 7th, 2009 at 10:37 am.
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

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

 
0
  #12
Jan 7th, 2009
Try Comatose's code, and tell what you get?
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 Quick reply to this message  
Join Date: Mar 2008
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

 
0
  #13
Jan 7th, 2009
okay that code returns no errors but how do i display the display names it finds in a combo or text box?
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

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

 
0
  #14
Jan 7th, 2009
Drag a comboBox and drop it into your form
Edit Comatose's code
  1. For Each skName In rk.GetSubKeyNames()
  2. sk = rk.OpenSubKey(skName)
  3. comboBox1.Items.Add(sk.GetValue("DisplayName"))
  4. Next skName
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 Quick reply to this message  
Join Date: Mar 2008
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

 
0
  #15
Jan 7th, 2009
okay, but when i run the code nothing gets returned in the box.

could it be the displayname part as if you go to the registry and pick a sub key, you will see displayname. When you click on display name the key is shown but its the 2nd part under value data i need.

as if i want a particular key for the processor i use
  1. Dim myCPUDescription As String = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0", "ProcessorNameString", "No CPU Found").ToString.Trim

and that returns the value data under the key
Last edited by smelf1; Jan 7th, 2009 at 11:57 am.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

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

 
0
  #16
Jan 7th, 2009
You shouldn't modify the function. The concept of a function, is that you shouldn't make them interact with the form. The idea of a function is that a function can be modular.... what if in the future, you decide to change it from a combobox, to a listbox... or save it to a file. Then you have to modify the function that actually GETS the display names of the registry keys. The purpose of a function is abstraction.... what this function does, is get the list of items in the registry (their display values) and returns them to the calling procedure. So for example, if you have a button, you would do:
  1. dim something as new arraylist
  2. something = GetInstalled()
  3. for I = 0 to something.count
  4. msgbox something(i)
  5. next I
It might have to be for I = 0 to something.count -1
Last edited by Comatose; Jan 7th, 2009 at 12:26 pm.
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

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

 
0
  #17
Jan 7th, 2009
I know Comatose, but it was my last chance to get him solve his problem!!!
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 Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

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

 
0
  #18
Jan 7th, 2009
I know why you did it, and were absolutely right... I just wanted to make the distinction for him, so that he understands the concepts. I would have suggested the same code mod you did
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
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

 
0
  #19
Jan 7th, 2009
ah right so the function is left alone so if i add a button i would now need to call that function from the code under the button.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

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

 
0
  #20
Jan 7th, 2009
Right, it returns an arraylist. So you would call it from the button, then assign the return value to an arraylist, and loop through it.
  1. dim something as new arraylist
  2. something = GetInstalled()
  3. for I = 0 to something.count
  4. msgbox something(i)
  5. next I
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC