程序安装时检查是否已经安装.NETFramework
2005-12-30 04:39
477 查看
添加新项中添加一个安装程序类
![](http://hqt.cnblogs.com/Images/OutliningIndicators/None.gif)
using System;
![](http://hqt.cnblogs.com/Images/OutliningIndicators/None.gif)
using System.Collections;
![](http://hqt.cnblogs.com/Images/OutliningIndicators/None.gif)
using System.ComponentModel;
![](http://hqt.cnblogs.com/Images/OutliningIndicators/None.gif)
using System.Configuration.Install;
![](http://hqt.cnblogs.com/Images/OutliningIndicators/None.gif)
using Microsoft.Win32;
![](http://hqt.cnblogs.com/Images/OutliningIndicators/None.gif)
using System.Diagnostics;
![](http://hqt.cnblogs.com/Images/OutliningIndicators/None.gif)
using System.IO;
![](http://hqt.cnblogs.com/Images/OutliningIndicators/None.gif)
namespace DOTNETCheck
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
/**//// <summary>
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
/// CheckDotnet 的摘要说明。
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
/// </summary>
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
[RunInstaller(true)]
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
public class CheckDotnet : System.Configuration.Install.Installer
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
/**//// <summary>
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
/// 必需的设计器变量。
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
/// </summary>
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
private System.ComponentModel.Container components = null;
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
public CheckDotnet()
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
// 该调用是设计器所必需的。
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
InitializeComponent();
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
// TODO: 在 InitComponent 调用后添加任何初始化
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
Component Designer generated code#region Component Designer ge
aeef
nerated code
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
/**//// <summary>
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
/// 此方法的内容。
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
/// </summary>
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
private void InitializeComponent()
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
components = new System.ComponentModel.Container();
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
#endregion
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
public override void Install(System.Collections.IDictionary stateSaver)
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//入口
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
RegistryKey key=null;
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
key = Registry.LocalMachine.CreateSubKey("Software//Microsoft//.NETFramework//policy//v1.0");
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
if(key==null||key.GetValue("3705")==null)
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
Process MyProcess=new Process();
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
MyProcess.StartInfo.FileName="dotnetfx.exe";
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
MyProcess.StartInfo.WindowStyle=ProcessWindowStyle.Hidden;
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
MyProcess.Start();
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
MyProcess.WaitForExit(); //等待程序执行
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
MyProcess.Close();
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://hqt.cnblogs.com/Images/OutliningIndicators/None.gif)
using System;
![](http://hqt.cnblogs.com/Images/OutliningIndicators/None.gif)
using System.Collections;
![](http://hqt.cnblogs.com/Images/OutliningIndicators/None.gif)
using System.ComponentModel;
![](http://hqt.cnblogs.com/Images/OutliningIndicators/None.gif)
using System.Configuration.Install;
![](http://hqt.cnblogs.com/Images/OutliningIndicators/None.gif)
using Microsoft.Win32;
![](http://hqt.cnblogs.com/Images/OutliningIndicators/None.gif)
using System.Diagnostics;
![](http://hqt.cnblogs.com/Images/OutliningIndicators/None.gif)
using System.IO;
![](http://hqt.cnblogs.com/Images/OutliningIndicators/None.gif)
namespace DOTNETCheck
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
/**//// <summary>
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
/// CheckDotnet 的摘要说明。
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
/// </summary>
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
[RunInstaller(true)]
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
public class CheckDotnet : System.Configuration.Install.Installer
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
/**//// <summary>
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
/// 必需的设计器变量。
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
/// </summary>
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
private System.ComponentModel.Container components = null;
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
public CheckDotnet()
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
// 该调用是设计器所必需的。
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
InitializeComponent();
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
// TODO: 在 InitComponent 调用后添加任何初始化
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
Component Designer generated code#region Component Designer ge
aeef
nerated code
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
/**//// <summary>
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
/// 此方法的内容。
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
/// </summary>
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
private void InitializeComponent()
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
components = new System.ComponentModel.Container();
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
#endregion
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
public override void Install(System.Collections.IDictionary stateSaver)
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//入口
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
RegistryKey key=null;
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
key = Registry.LocalMachine.CreateSubKey("Software//Microsoft//.NETFramework//policy//v1.0");
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
if(key==null||key.GetValue("3705")==null)
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
Process MyProcess=new Process();
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
MyProcess.StartInfo.FileName="dotnetfx.exe";
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
MyProcess.StartInfo.WindowStyle=ProcessWindowStyle.Hidden;
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
MyProcess.Start();
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
MyProcess.WaitForExit(); //等待程序执行
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
MyProcess.Close();
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://hqt.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://hqt.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
}
相关文章推荐
- 程序安装时检查是否已经安装.NETFramework [转]
- 程序安装时检查是否已经安装.NETFramework [转]
- 程序安装时检查是否已经安装.NETFramework [转]
- 程序安装时检查是否已经安装.NETFramework
- 程序安装时检查是否已经安装.NETFramework
- 程序安装时检查是否已经安装.NETFramework
- 检查机器是否安装了.NET Framework 或已经安装了哪些.net版本
- C++检测系统是否已经安装了.NET Framework
- 用dos批处理程序检测是否安装.netframework,并自动安装后运行指定程序(.net自启动光盘的制做)
- 怎样从ASP.NET程序判断客户端是否安装了.NET Framework
- 怎样用ASP.NET(C#)程序判断客户端是否安装了.NET Framework
- 在Inno Setup制作的安装包中利用Pascal脚本检查安装,卸载前检查程序是否已经启动 [转载]
- 用dos批处理程序检测是否安装.netframework,并自动安装后运行指定程序(.net自启动光盘的制做)
- 检查PC是否安装NET  Framework
- Setup Factory 打包程序 --程序安装前判断本机是否安装.NET Framework和SQL Server
- 程序运行初期检查是否已经有一个自身的进程在运行,保证一台PC机器只运行一个程序
- 安装程序自动检测安装.Net Framework运行环境(使用InnoSetup)
- 不安装.NET Framework 运行C#.NET程序
- 检查RPM包是否已经安装
- 检查机器是否安装有.net