Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5931527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:42:27+00:00 2026-05-22T14:42:27+00:00

I have already looked at existing topics, so please try to refrain from dropping

  • 0

I have already looked at existing topics, so please try to refrain from dropping links here.

I want to get the value of a registry key – plain and simple. Here is what I have so far.

Registry:
1) Made a key under

Current_User\Software\Custom_Subkey\Custom_Value\Custom_key\string_value

I am trying to find the string_value

        string reg_subKey = "Software\\Custom_Subkey\\Custom_Value";

        RegistryKey root = Registry.CurrentUser.CreateSubKey(reg_subKey);


        foreach (string keyname in root.GetValueNames())
        {
            textBox4.AppendText(keyname.ToString() + Environment.NewLine);

// Appends the following data to textBox4 once the foreach is completed:
// Header1
// Header2
// Header3
// Header4
// Header5

// Now I want to get the VALUES of each header:

            using (RegistryKey key = root.OpenSubKey(keyname))
            {

**// THIS LINE GETS HIGHLIGHTED WITH THE FOLLOWING ERROR:
"Object reference not set to an instance of an object.**"
                MessageBox.Show(key.ValueCount.ToString());
            }
        }

Hopefully this is a simple fix. I look forward to hearing your responses.
Thanks,
Evan

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T14:42:27+00:00Added an answer on May 22, 2026 at 2:42 pm

    I believe you want root.GetSubKeyNames() in the loop not GetValueNames()

    While values is working to get the values I would suggest the following loop:

    foreach(string keyname in root.GetSubKeyNames())
    {
        // use key to get value and set textbox4
    
    
        using (RegistryKey key = root.OpenSubKey(keyname))
        {
           MessageBox.Show(key.ValueCount.ToString());
        }
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have already looked at some array topics but I am still stumped. I
i know, similar questions have been asked, and i've already looked through everything i
I have already posted something similar here but I would like to ask the
I have already created a webpart to show the data from list, but I
At work, I'm trying to get n-tier model implemented in a large already existing
I've already looked at this , which was helpful to a point. Here's the
We already have a good build server in Hudson but we want something that
I have already searched about this issue, analyzed several open source tools (like Ganymed
I have already tried PreRenderComplete and unload is too late
I have already googled for this I have a Table with following structure in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.