您的位置:首页 > 其它

如何检测是否安装了.NET 2.0和.NET 3.0 [ZT]

2007-10-07 20:47 274 查看

代码来自Paint.NET的PaintDotNet.SystemLayer.OS类

这段代码是通过检查注册表中的项来确定.NET 2.0/3.0是否安装的。由于Paint.NET是由微软员工参与开发的,可以认为这是比较准确的判断方法。

private static bool IsDotNet2VersionInstalled(int major, int minor, int build)

private static bool IsDotNet3VersionInstalled(int major, int minor, int build)

private static bool CheckForRegValueEquals1(string regKeyName, string regValueName)
using (RegistryKey key = Registry.LocalMachine.OpenSubKey(regKeyName, false))
object value = null;

if (key != null)
value = key.GetValue(regValueName);
}

return (value != null && value is int && (int)value == 1);
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: