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

  • Home
  • SEARCH
  • 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 8763937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:54:04+00:00 2026-06-13T15:54:04+00:00

So I’m writing some code and using RegistryKey.GetValue and I can’t seem to get

  • 0

So I’m writing some code and using RegistryKey.GetValue and I can’t seem to get it to return the proper string array. I would use RegSaveKeyEx except I need to change the location of where the keys are being saved to in the reg file I’m creating.

The MultiString I’m querying has two lines in it, : and a blank line. Regedit gives hex(7):3a,00,00,00,00,00 for the reg file export of said value. This is correct. 3a would be :, then a null, two nulls for the blank line and finally two more nulls to signify the end of the value. My code is giving hex(7):3a,00,00,00, which would be a : and the double-null EOL characters on a MultiString. When imported back into the registry hex(7):3a,00,00,00 is only a :, the blank line is missing.

If I import hex(7):3a,00,00,00,00,00 then view the value in regedit, I see : and a blank line. This is correct and this is what I want my code to do.

When I query this value with RegistryKey.GetValue in C# 4.0 I get the a string[] with just one element, the :.

For other MultiString values I get an array containing an element for every line, as I would expect.

RegistryKey.GetValue doesn’t return anything for the blank line. It doesn’t return a null, a blank string in the array, nothing.

On everything except blank lines it returns exactly the same result as regedit export. What needs to be changed to have it return an array that includes the blank line?

Here’s my code if that’s helpful:

private static string RegMultiStringExtraction(RegistryKey UsersSubKey, string Key)
    {
        string[] InputStrs = (string[])UsersSubKey.GetValue(Key, Environment.NewLine, RegistryValueOptions.DoNotExpandEnvironmentNames);
        StringBuilder sb = new StringBuilder();
        foreach (string str in InputStrs)
        {
            char[] Values = str.ToCharArray();
            foreach (char letter in Values)
            {
                int ValueInt = Convert.ToInt32(letter);
                sb.Append(ValueInt.ToString("x"));
                sb.Append(",00,");
                if (Values.Length == 0)
                {
                    if (sb.Length == 0)
                    {
                        sb.Append("00,");
                    }
                    else if (sb.Length > 1)
                    {
                        sb.Append(",00,");
                    }
                }
            }
            sb.Append("00,00,");
        }

        string Value = ('"' + Key.ToString() + @"""=" + "hex(7):" + sb.ToString().TrimEnd(','));
        return Value;
    }
  • 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-06-13T15:54:08+00:00Added an answer on June 13, 2026 at 3:54 pm

    Double null-terminated strings cannot contain empty lines. An attempt to include empty lines means including two consecutive nulls, and that is interpreted as termination rather than an empty line. Raymond Chen discussed this quirk much more eloquently that I can.

    Perhaps you can save to REG_SZ and use Environment.NewLine as a delimiter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I would like to count the length of a string with PHP. The string
Does anyone know how can I replace this 2 symbol below from the string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I am reading a book about Javascript and jQuery and using one of the
I've got a string that has curly quotes in it. I'd like to replace

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.