Results 1 to 6 of 6

Thread: [RESOLVED] Registry Into Combobox?

  1. #1

    Thread Starter
    Addicted Member GedOfEarthsea's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    145

    Resolved [RESOLVED] Registry Into Combobox?

    Hello, I am currently making a program in Visual Basic Studio 2005 and I wanted to know if it was possible to be able to read the registry and have all the strings in the folder added into a combobox. What I mean is if I can get all of the strings from a folder like HKCU\Software\Microsoft\Internet Explorer\TypedURLs\ and add them into a combobox line by line? If could someone please give an explanation?

    Thanks

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: Registry Into Combobox?

    Why not just set the AutoComplete thingy to URLs?
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  3. #3

    Thread Starter
    Addicted Member GedOfEarthsea's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    145

    Re: Registry Into Combobox?

    It isn't for that, I was just using an example.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Registry Into Combobox?

    VB Code:
    1. Dim regKey As Microsoft.Win32.RegistryKey = My.Computer.Registry.CurrentUser.OpenSubKey("Software\Microsoft\Internet Explorer\TypedURLs")
    2. Dim valueNames As String() = regKey.GetValueNames()
    3. Dim upperBound As Integer = valueNames.GetUpperBound(0)
    4. Dim values(upperBound) As String
    5.  
    6. For i As Integer = 0 To upperBound Step 1
    7.     values(i) = CStr(regKey.GetValue(valueNames(i)))
    8. Next i
    9.  
    10. Me.ComboBox1.Items.AddRange(values)
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Registry Into Combobox?

    Now, that's assuming that all the values ARE strings. If they're not then I think this should work anyway:
    VB Code:
    1. Dim regKey As Microsoft.Win32.RegistryKey = My.Computer.Registry.CurrentUser.OpenSubKey("Software\Microsoft\Internet Explorer\TypedURLs")
    2. Dim valueNames As String() = regKey.GetValueNames()
    3. Dim upperBound As Integer = valueNames.GetUpperBound(0)
    4. Dim values(upperBound) As Object
    5.  
    6. For i As Integer = 0 To upperBound Step 1
    7.     values(i) = regKey.GetValue(valueNames(i))
    8. Next i
    9.  
    10. Me.ComboBox1.Items.AddRange(values)
    I believe that that will simply call the ToString method of each object so if it isn't a string already it will be converted to one. For some types that will not display the actual data, like REG_BINARY, but at least it will not crash.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  6. #6

    Thread Starter
    Addicted Member GedOfEarthsea's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    145

    Re: Registry Into Combobox?

    Thanks a lot, works great.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width