0

I use this code to read values from the registry:

appManufacturer = (string)subKey.GetValue("Publisher");

This is result: enter image description here

The value in the registry looks like this: enter image description here

When I looked at the string during debugging value was "Microsoft \0". Why? Where did "\0" comes from? What do i do wrong here?

Michal
  • 713
  • 1
  • 7
  • 23
  • Its always been there ... [Related: What does the \0 symbol mean in a C string?](http://stackoverflow.com/q/4711449/1324033) – Sayse Oct 29 '15 at 12:02
  • @Sayse While that explains what it is, it doesn't explain why it's there. If registries store the null-character, then one would expect the .NET library to handle that automatically. That being said, I've accessed registry entries via .NET and never encountered the null-char, so something seems fishy about this entry. – Rob Oct 29 '15 at 12:26
  • 1
    @Rob - I was more trying to just explain what it was rather than offer a solution – Sayse Oct 29 '15 at 12:29

1 Answers1

-1

The below code will allow you to get a registry value.

    string keyname = "SAVCE";
    Console.WriteLine(Read(keyname));    

    public static string Read(string KeyName)
    {
        using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(@"Software\Symantec\InstalledApps"))
        {
            return (string)registryKey.GetValue(KeyName);
        }

    }
zXSwordXz
  • 164
  • 4
  • 15
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – Roman Marusyk Oct 29 '15 at 17:22