Results 1 to 9 of 9

Thread: [RESOLVED] Read Startup Program In Regsity and Put in ListView

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2012
    Posts
    23

    Resolved [RESOLVED] Read Startup Program In Regsity and Put in ListView

    I'm trying trying to add a feature to a program i'm working on that puts the start up programs on a system into a listview.

    The start up items are stored in the following registry location:
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run

    What I would like to do is read the Program Name value under the Name Column in the registry and the Data Value under the Data value and put these values into the listview in two seperate columns like Msconfig utility see the screen shot.

    I'm familiar with working with the registry in .NET, but I can't seem to get this to work. I believe I would need to loop through each registyvaluename under this key and get the name and value.

    Thanks,
    Attached Images Attached Images   
    Last edited by TechMe.NET; Jan 27th, 2012 at 02:31 PM.

  2. #2
    Master Of Orion ForumAccount's Avatar
    Join Date
    Jan 2009
    Location
    Canada
    Posts
    2,802

    Re: Help

    Please don't name your threads "Help". It helps us help you if you name your thread something relevant to your issue.

    Anyway, I'm not sure I understand where you are having a problem. Can you post your code?

  3. #3
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,713

    Re: [RESOLVED] Help

    This is the raw code where GetValueNames provides you with just that names and then use GetValue for each one. Place the pairs into a container that you can sort A-Z, done.

    Does not cover Default item

    Code:
    Dim regKey As RegistryKey
    regKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", False)
    Dim Names = regKey.GetValueNames
    For Each Item In Names
        Console.WriteLine("{0} = {1}", Item, regKey.GetValue(Item))
    Next
    regKey.Close()

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Jan 2012
    Posts
    23

    Re: [RESOLVED] Help

    Thanks for the reply Kevin. Could you please explain how to display the data out to a listbox/text for example.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jan 2012
    Posts
    23

    Re: Read Startup Program In Regsity and Put in ListView

    This is what I get with the console.writeline this is essentially the information i'm trying to list in a listview.
    Attached Images Attached Images  

  6. #6
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,713

    Re: Read Startup Program In Regsity and Put in ListView

    Using a DataGridView
    Code:
    Private Sub PopulateRegDemo()
        Dim dt As New DataTable
        dt.Columns.AddRange(New DataColumn() _
            { _
                New DataColumn("StartUpItem", GetType(System.String)), _
                New DataColumn("RunCommand", GetType(System.String)) _
            } _
        )
    
        Dim regKey As Microsoft.Win32.RegistryKey
        regKey = Microsoft.Win32.Registry.LocalMachine _ 
           .OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", False)
        Dim Names = regKey.GetValueNames
        For Each Item In Names
            dt.Rows.Add(New Object() {Item, regKey.GetValue(Item).ToString.Replace(Chr(34), "")})
        Next
        regKey.Close()
    
        dt.DefaultView.Sort = "StartUpItem"
        DataGridView1.DataSource = dt.DefaultView
    End Sub

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Jan 2012
    Posts
    23

    Resolved Re: Read Startup Program In Regsity and Put in ListView

    Thanks for you help! I figured out how to list the items in a listview as well. My msconfig like utility is almost complete!

    Thanks!

  8. #8
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,713

    Re: [RESOLVED] Read Startup Program In Regsity and Put in ListView

    Good to hear you are making head way. It would be intersting to know why this thread recieved a one star rating as this indicates a Terrible thread.

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Jan 2012
    Posts
    23

    Re: [RESOLVED] Read Startup Program In Regsity and Put in ListView

    Not sure i just rated 5 stars.

    Quote Originally Posted by kevininstructor View Post
    Good to hear you are making head way. It would be intersting to know why this thread recieved a one star rating as this indicates a Terrible thread.

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