Registry to listview? Help.

How might I go about getting registry keys to apear with my listview.

Page 1 of 1

3 Replies - 2503 Views - Last Post: 01 June 2010 - 08:47 PM Rate Topic: -----

#1 knobody  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 01-June 10

Registry to listview? Help.

Posted 01 June 2010 - 12:15 PM

I have setup my listview to View:Details
I want the listview to show all the keys of a specific folder.
Example: HKEY_CURRENT_USER\Software\Microsoft\VBExpress\10.0

So you click button1 and it adds all the keys within the example to your listview.

I found an old thread about registry but it was too advanced for me to understand. Edit: not too advanced but more like not specific to my needs.
Old thread.

This post has been edited by knobody: 01 June 2010 - 12:21 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Registry to listview? Help.

#2 knobody  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 01-June 10

Re: Registry to listview? Help.

Posted 01 June 2010 - 01:14 PM

This is what I have tried.
Imports Microsoft.Win32
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim lSItem As ListViewItem
lsItem = ListView1.Items.Add(My.Computer.Registry.CurrentUser.OpenSubKey("HKEY_CURRENT_USER\Software\Microsoft\VBExpress\10.0").GetValueNames() as string(), 0)


The problem i see right away is it's impossible to write a string into one column of a list view. And the second is that won't work because I am missing a ')' somewhere...
Was This Post Helpful? 0
  • +
  • -

#3 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1605
  • View blog
  • Posts: 5,162
  • Joined: 25-September 09

Re: Registry to listview? Help.

Posted 01 June 2010 - 01:57 PM

OK, I was distracted at work, so now that I've had time, here is what I think you are trying to do

   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim Results() As String
        Results= Registry.CurrentUser.OpenSubKey("Software\Microsoft", False).GetSubKeyNames
        For x As Integer = 0 To Results.Count - 1
            Dim lv As New ListViewItem
            lv.Text = Results(x).ToString
            ListView1.Items.Add(lv)
        Next
    End Sub



Don't forget to include Imports Microsoft.Win32

And you will need to change your string for your subkey, I don't have VSExpress installed so I get nothing back from it.

The reason I like using this method to populate the listview is that it makes it easy to add more columns. Then all you would have to do after adding the columns to your listview is add like the ones that follow, below the lv.text line like so
lv.subitems.add("data for column2")
lv.subitems.add("data for column3")

and so on...

One other thing, my example uses GetSubKeyNames, you will have to put the actual key in the string and change it to GetValueNames to get the list of values. That's all you should have to change though.

This post has been edited by CharlieMay: 01 June 2010 - 03:02 PM

Was This Post Helpful? 1
  • +
  • -

#4 knobody  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 01-June 10

Re: Registry to listview? Help.

Posted 01 June 2010 - 08:47 PM

I love you! thank you so much, with a little modification I was able to achieve everything I wanted!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1