The following code is executable directly in LinqPad too, you can get the perfect LinqPad tool (free) by (Joseph Albahari) here.
// Microsoft.Win32
// System
void Main()
{
RegistryKey ndpKey = RegistryKey.OpenBaseKey(
RegistryHive.LocalMachine
, RegistryView.Registry32).OpenSubKey(
@"SOFTWARE\Microsoft\NET Framework Setup\NDP\");
foreach (string verKeyName in ndpKey.GetSubKeyNames())
{
if (verKeyName.StartsWith("v"))
{
RegistryKey verKey =
ndpKey.OpenSubKey(verKeyName);
string name =
(string)verKey.GetValue("Version", "");
string sp =
verKey.GetValue("SP", "").ToString();
string install =
verKey.GetValue("Install", "").ToString();
if (install == "")
Console.WriteLine(
verKeyName + " " + name);
else if (sp != "" && install == "1")
Console.WriteLine(
verKeyName + " " + name + " SP" + sp);
if (name != "") continue;
foreach (string subKeyName in verKey.GetSubKeyNames())
{
RegistryKey subKey =
verKey.OpenSubKey(subKeyName);
name = (string)subKey.GetValue("Version", "");
if (name != "")
sp = subKey.GetValue("SP", "").ToString();
install = subKey.GetValue("Install", "").ToString();
if (install == "")
Console.WriteLine(verKeyName + " " + name);
else if (sp != "" && install == "1")
Console.WriteLine(
" " + subKeyName + " " + name + " SP" + sp);
else if (install == "1")
Console.WriteLine(
" " + subKeyName + " " + name);
}
}
}
}
No comments:
Post a Comment