参考文章http://www.cnblogs.com/hanfeng/archive/2005/03/03/112246.html
http://liuluanqing.blog.ccidnet.com/blog-htm-do-showone-uid-16196-type-blog-itemid-128023.html
第一步:引用空间
//系统默认空间添加
using System;
//添加对注册表操作所需引用空间
using Microsoft.Win32;
第二步:添加函数
//检测目标机器上是否安装Microsoft .NETFramework 1.1平台
public bool DoesDotNETFrameworkExist(string udeVersion)
{
bool ExistFlag=false;
RegistryKey hkml = Registry.LocalMachine;
RegistryKey mySubKey1 = hkml.OpenSubKey("SOFTWARE",true);
RegistryKey mySubKey2 = mySubKey1.OpenSubKey("Microsoft",true);
string[] myKeyNames1= mySubKey2.GetSubKeyNames();
foreach(string tempKey1 in myKeyNames1)
{
if(tempKey1 == ".NETFramework")
{
RegistryKey mySubKey3 = mySubKey2.OpenSubKey(".NETFramework",true);
string[] myKeyNames2= mySubKey3.GetSubKeyNames();
foreach(string tempKey2 in myKeyNames2)
{
if(tempKey2 == "policy")
{
RegistryKey mySubKey4 = mySubKey3.OpenSubKey("policy",true);
string[] myKeyNames3= mySubKey4.GetSubKeyNames();
foreach(string tempKey3 in myKeyNames3)
{
if(tempKey3 == "v1.1")
{
MessageBox.Show(tempKey3);
ExistFlag=true;
break;
}
}
break;
}
}
break;
}
}
return ExistFlag;
}
备注说明:当前代码基本修改来自VB版本的C#检测目标机器上是否安装Microsoft .NETFramework 1.1平台