Saturday, December 29, 2007

C#: Read all registry values under a key

public string[,] ReadRegistryValues(Microsoft.Win32.RegistryKey regHive, string regKey)
{
string[,] values = null;

Microsoft.Win32.RegistryKey key = regHive.OpenSubKey(regKey);
string[] valNames = key.GetValueNames();
values = new string[valNames.Length,2];
for (int i = 0; i < valNames.Length; i++)
{
values[i,0] = valNames[i];
values[i,1] = (string)key.GetValue(valNames[i]);
}

return values;
}

No comments:

Post a Comment

Please use your common sense before making a comment, and I truly appreciate your constructive criticisms.