[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
Re: Registry Into Combobox?
Why not just set the AutoComplete thingy to URLs?
Re: Registry Into Combobox?
It isn't for that, I was just using an example.
Re: Registry Into Combobox?
VB Code:
Dim regKey As Microsoft.Win32.RegistryKey = My.Computer.Registry.CurrentUser.OpenSubKey("Software\Microsoft\Internet Explorer\TypedURLs")
Dim valueNames As String() = regKey.GetValueNames()
Dim upperBound As Integer = valueNames.GetUpperBound(0)
Dim values(upperBound) As String
For i As Integer = 0 To upperBound Step 1
values(i) = CStr(regKey.GetValue(valueNames(i)))
Next i
Me.ComboBox1.Items.AddRange(values)
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:
Dim regKey As Microsoft.Win32.RegistryKey = My.Computer.Registry.CurrentUser.OpenSubKey("Software\Microsoft\Internet Explorer\TypedURLs")
Dim valueNames As String() = regKey.GetValueNames()
Dim upperBound As Integer = valueNames.GetUpperBound(0)
Dim values(upperBound) As Object
For i As Integer = 0 To upperBound Step 1
values(i) = regKey.GetValue(valueNames(i))
Next i
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.
Re: Registry Into Combobox?
Thanks a lot, works great.