The approach to fishing something out of the registry needs to vary conditionally.
public string Fish(string lure)
{
string fishingGrounds = @"SOFTWARE\Something\Er\Other\";
if (!_myHashtable.ContainsKey(lure))
{
if (Environment.Is64BitOperatingSystem)
{
RegistryKey fish = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine,
RegistryView.Registry64).OpenSubKey(fishingGrounds);
_myHashtable.Add(lure, fish.GetValue(lure));
fish.Close();
}
else
{
RegistryKey fish = Registry.LocalMachine.OpenSubKey(fishingGrounds);
_myHashtable.Add(lure, fish.GetValue(lure));
fish.Close();
}
}
return _myHashtable[lure].ToString();
}
Environment is in the System namespace (System.Environment) and the registry flavored stuff is in the Microsoft.Win32 namespace.
No comments:
Post a Comment