registry key

Discussion in 'ASP .Net' started by =?Utf-8?B?QVZM?=, Sep 19, 2007.

  1. hi,
    i've a requirement to scan the registry keys programatically in a console
    application and read the data of the keys..
    given a registry key, say,"HKEY_USERS". user should be able to scan the
    subkeys of the given key recursively(i.e. all the subkeys of the given
    subkeys etcc..) till the last indent level....

    i've used a recursion to do so..but it's taking lot of time..
    is there any efficient way to acheive it.....
    =?Utf-8?B?QVZM?=, Sep 19, 2007
    #1
    1. Advertising

  2. "AVL" <> wrote in message
    news:D...

    > in a console application


    This is an ASP.NET newsgroup - you'll generally get better responses by
    posting in the correct group...

    Anyway...

    > given a registry key, say,"HKEY_USERS". user should be able to scan the
    > subkeys of the given key recursively(i.e. all the subkeys of the given
    > subkeys etcc..) till the last indent level....
    >
    > i've used a recursion to do so..but it's taking lot of time..
    > is there any efficient way to acheive it.....


    Dictionary<string, string> dicSubKeyNamesAndValues = new Dictionary<string,
    string>();
    using (RegistryKey objRegKey =
    RegistryKey.OpenRemoteBaseKey(RegistryHive.Users, "<machine name>"))
    {
    using (RegistryKey objSubKey = objRegKey.OpenSubKey("<key to start
    from">))
    {
    if (objSubKey!= null)
    {
    foreach (string strSubKey in objSubKey.GetValueNames())
    {
    dicSubKeyNamesAndValues.Add(strSubKey,
    objRegKey.GetValue(strSubKey).ToString());
    }
    }
    }
    }


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
    Mark Rae [MVP], Sep 19, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. HK
    Replies:
    1
    Views:
    3,622
    Cowboy \(Gregory A. Beamer\)
    Apr 1, 2004
  2. Replies:
    0
    Views:
    747
  3. Leny
    Replies:
    3
    Views:
    16,918
    Daniel
    Feb 1, 2005
  4. M P
    Replies:
    1
    Views:
    463
  5. Collin Miller
    Replies:
    10
    Views:
    591
    Roger Pack
    Jul 9, 2010
Loading...

Share This Page