天天看点

程序安装时检查是否已经安装.NETFramework

添加新项中添加一个安装程序类

程序安装时检查是否已经安装.NETFramework

using System;

程序安装时检查是否已经安装.NETFramework

using System.Collections;

程序安装时检查是否已经安装.NETFramework

using System.ComponentModel;

程序安装时检查是否已经安装.NETFramework

using System.Configuration.Install;

程序安装时检查是否已经安装.NETFramework

using Microsoft.Win32;

程序安装时检查是否已经安装.NETFramework

using System.Diagnostics;

程序安装时检查是否已经安装.NETFramework

using System.IO;

程序安装时检查是否已经安装.NETFramework

namespace DOTNETCheck

程序安装时检查是否已经安装.NETFramework

{

程序安装时检查是否已经安装.NETFramework

    /// <summary>

程序安装时检查是否已经安装.NETFramework

    /// CheckDotnet 的摘要说明。

程序安装时检查是否已经安装.NETFramework

    /// </summary>

程序安装时检查是否已经安装.NETFramework

    [RunInstaller(true)]

程序安装时检查是否已经安装.NETFramework

    public class CheckDotnet : System.Configuration.Install.Installer

程序安装时检查是否已经安装.NETFramework

    {

程序安装时检查是否已经安装.NETFramework

        /// <summary>

程序安装时检查是否已经安装.NETFramework

        /// 必需的设计器变量。

程序安装时检查是否已经安装.NETFramework

        /// </summary>

程序安装时检查是否已经安装.NETFramework

        private System.ComponentModel.Container components = null;

程序安装时检查是否已经安装.NETFramework
程序安装时检查是否已经安装.NETFramework

        public CheckDotnet()

程序安装时检查是否已经安装.NETFramework

        {

程序安装时检查是否已经安装.NETFramework

            // 该调用是设计器所必需的。

程序安装时检查是否已经安装.NETFramework

            InitializeComponent();

程序安装时检查是否已经安装.NETFramework
程序安装时检查是否已经安装.NETFramework

            // TODO: 在 InitComponent 调用后添加任何初始化

程序安装时检查是否已经安装.NETFramework
程序安装时检查是否已经安装.NETFramework
程序安装时检查是否已经安装.NETFramework

        }

程序安装时检查是否已经安装.NETFramework
程序安装时检查是否已经安装.NETFramework

        Component Designer generated code

程序安装时检查是否已经安装.NETFramework
程序安装时检查是否已经安装.NETFramework

        public override void Install(System.Collections.IDictionary stateSaver)

程序安装时检查是否已经安装.NETFramework
程序安装时检查是否已经安装.NETFramework
程序安装时检查是否已经安装.NETFramework

            //入口

程序安装时检查是否已经安装.NETFramework

            RegistryKey key=null;

程序安装时检查是否已经安装.NETFramework

            key = Registry.LocalMachine.CreateSubKey("Software\\Microsoft\\.NETFramework\\policy\\v1.0");

程序安装时检查是否已经安装.NETFramework

            if(key==null||key.GetValue("3705")==null)

程序安装时检查是否已经安装.NETFramework

            {

程序安装时检查是否已经安装.NETFramework

                    Process MyProcess=new Process(); 

程序安装时检查是否已经安装.NETFramework

                    MyProcess.StartInfo.FileName="dotnetfx.exe";

程序安装时检查是否已经安装.NETFramework

                    MyProcess.StartInfo.WindowStyle=ProcessWindowStyle.Hidden;

程序安装时检查是否已经安装.NETFramework

                    MyProcess.Start();

程序安装时检查是否已经安装.NETFramework

                    MyProcess.WaitForExit(); //等待程序执行

程序安装时检查是否已经安装.NETFramework

                    MyProcess.Close();

程序安装时检查是否已经安装.NETFramework

            }

程序安装时检查是否已经安装.NETFramework
程序安装时检查是否已经安装.NETFramework
程序安装时检查是否已经安装.NETFramework

    }

程序安装时检查是否已经安装.NETFramework

}

程序安装时检查是否已经安装.NETFramework

本文转自高海东博客园博客,原文链接:http://www.cnblogs.com/ghd258/archive/2005/10/25/262052.html,如需转载请自行联系原作者

继续阅读