|  设为首页  |  加入收藏  
首    页 关于我们 新闻中心 产品世界 相关下载 工程案例 人才招聘 联系我们

此页面上的内容需要较新版本的 Adobe Flash Player。

获取 Adobe Flash Player

产品展示 [更多]
解决方案 [更多]
省会部分小区有了远程室温监测仪
供热期间,怎样测量室内温度更合理?
供热住户温度采集方案
温湿度监控系统产品其他应用场合
供暖测温退费新规出台
让居民过一个温暖的冬天,是我们义不
无线室温远程采集控制系统
室内测温远传系统
技术文献 [更多]
如何应对手术室室温管理的矛盾
供暖管理-无线远程测温系统
供热温度标准到底是多少?
供暖 供热温度将随气温调整
供暖测温谁说了算
供热无线测温 少些争议更舒适
供暖温度检测系统
大体积混凝土测温点布置原则
       技术文献
Author:Jwztech.com Date: 2011/9/20 Hits: 1243

C# 如何检测是否安装了.NET 2.0和.NET 3.0

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

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

 

        private static bool IsDotNet2VersionInstalled(int major, int minor, int build)
src=http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif        
{
src=http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif            
const string regKeyNameFormat = Software\\Microsoft\\NET Framework Setup\\NDP\\v{0}.{1}.{2};
src=http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif            
const string regValueName = Install;
src=http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif
src=http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif            
string regKeyName = string.Format(regKeyNameFormat, major.ToString(CultureInfo.InvariantCulture),
src=http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif                minor.ToString(CultureInfo.InvariantCulture), build.ToString(CultureInfo.InvariantCulture));
src=http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif
src=http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif            
return CheckForRegValueEquals1(regValueName, regKeyName);
src=http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif        }

src=http://www.cnblogs.com/Images/OutliningIndicators/None.gif
src=http://www.cnblogs.com/Images/OutliningIndicators/None.gif        
private static bool IsDotNet3VersionInstalled(int major, int minor, int build)
src=http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif        
{
src=http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif            
bool result = false;
src=http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif
src=http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif            
const string regValueName = InstallSuccess;
src=http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif
src=http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif            
if (!result)
src=http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif            
{
src=http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif                
const string regKeyNameFormat = Software\\Microsoft\\NET Framework Setup\\NDP\\v{0}.{1}\\Setup;
src=http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif                
string regKeyName = string.Format(regKeyNameFormat, major, minor);
src=http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif
src=http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif                result 
|= CheckForRegValueEquals1(regKeyName, regValueName);
src=http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif            }

src=http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif
src=http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif            
if (!result)
src=http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif            
{
src=http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif                
// There seems to be a bug in x64 .NET 3.0 where it only records its success in the 32-bit section of the registry.
src=http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif
                const string regKeyNameFormat2 = Software\\Wow6432Node\\Microsoft\\NET Framework Setup\\NDP\\v{0}.{1}\\Setup;
src=http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif                
string regKeyName2 = string.Format(regKeyNameFormat2, major, minor);
src=http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif
src=http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif                result 
|= CheckForRegValueEquals1(regKeyName2, regValueName);
src=http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif            }

src=http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif
src=http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif            
return result;
src=http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif        }

src=http://www.cnblogs.com/Images/OutliningIndicators/None.gif
src=http://www.cnblogs.com/Images/OutliningIndicators/None.gif        
private static bool CheckForRegValueEquals1(string regKeyName, string regValueName)
src=http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif        
{
src=http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif            
using (RegistryKey key = Registry.LocalMachine.OpenSubKey(regKeyName, false))
src=http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif            
{
src=http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif                
object value = null;
src=http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif
src=http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif                
if (key != null)
src=http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif                
{
src=http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif                    value 
= key.GetValue(regValueName);
src=http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif                }

src=http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif
src=http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif                
return (value != null && value is int && (int)value == 1);
src=http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif            }

src=http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif        }

 
版权所有:唐山金万众科技有限公司  最佳浏览:1440*900分辩率    冀公网安备 13020302000819号
Copyright JWZ Science & Technology CO.,Ltd. All Rights Reserved 2006-2026