0

Hi i want to know how many lines of data there are in a regedit key of the user for example

Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SystemInformation\ComputerHardwareIds

In my case i have 10 lines of GUID's in there, so how do i do this in c#?

1 Answer 1

0

From that link Registry Data Types (exists next to value name in registry)

REG_SZ Null-terminated string. It will be a Unicode or ANSI string, depending on whether you use the Unicode or ANSI functions.
REG_MULTI_SZ Array of null-terminated strings that are terminated by two null characters.

Depending on that answer just edited it a bit to match your request.

using (RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Control\SystemInformation")) { if (key != null) { object value = key.GetValue("ComputerHardwareIds"); if (value != null) { var computerHardwareIds = (value as string[]); // cast value object to string array, because its type is REG_MULTI_SZ var lines_num = computerHardwareIds.Length; // then you can get lines number this way } } } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.