在用户界面的启动中添加了文本框,我想接受输入,然后判断,比如说吧,输入了数据库用户和密码,验证是否正确,正确就继续,不正确就不显示下一个界面,可以控制吗用户界面里面的对话框可以控制吗,如何写代码呢,我就知道继承installer类,然后呢 [RunInstaller(true)]
    public partial class Installer1 : Installer
    {
        private string dbname;
        private string dbserver;
        private string username;
        private string password;        public Installer1()
        {
            InitializeComponent();
        }
        public override void Install(IDictionary stateSaver)
        {                    dbname = "DevTest";
            dbserver = this.Context.Parameters["dbserver"].ToString();
            username = this.Context.Parameters["username"].ToString();
            password = this.Context.Parameters["password"].ToString();
 base.Install(stateSaver);
            
        }
        protected override void OnAfterInstall(IDictionary savedState)
        {
            base.OnAfterInstall(savedState);
            Form1 frm = new Form1();
            frm.ShowDialog();
        }
        protected override void OnBeforeInstall(IDictionary savedState)
        {            base.OnBeforeInstall(savedState);             
        }
        protected override void OnCommitting(IDictionary savedState)
        {
            Form1 form1 = new Form1();            if (form1.ShowDialog() == DialogResult.OK)
            {
                using (SqlConnection conn = new SqlConnection(form1.ConnString))
                {
                    conn.Open();
                           if (conn.State==ConnectionState.Open)
                    {
                        Form2 frm = new Form2();
                        frm.ShowDialog();
                    }                }
            }
            base.OnCommitting(savedState);
        }
        public override void Uninstall(IDictionary savedState)
        {
            if (savedState == null)
                throw new ApplicationException("uninstall error");
            else
                base.Uninstall(savedState);
        }
    }Form1 form1 = new Form1();这个是我的自定义窗体,我写在那里方法下面才可以自定义呢,是安装有一个向导,配置好才可以继续,就像添加数据源还要先验证数据库登录那样,才可以选择表啊什么的,不知道我说的大家都明白吗,给点提示吧
msdn,google,我都找遍了,两天了,没有头绪啊,
大部分的帖子都是说添加,但是没有控制啊,取值可以用dbname = "DevTest";
            dbserver = this.Context.Parameters["dbserver"].ToString();
            username = this.Context.Parameters["username"].ToString();
            password = this.Context.Parameters["password"].ToString();我知道,但是我怎么才可以控制用户界面加入的窗体呢,就算不控制他的,我自己写一些,又怎么来和他的安装过程集成呢,就像先出现我的验证,然后继续他的安装进度,谢谢了!

解决方案 »

  1.   

    我公司不可以上QQ,MSN还可以上,
      

  2.   

    namespace ClassLibrary1
    {
        [RunInstaller(true)]
        public class Installer : System.Configuration.Install.Installer
        {
            public override void Install(IDictionary stateSaver)
            {
                base.Install(stateSaver);
                Form1 hc = new Form1();
                MessageBox.Show(this.Context.Parameters["targetdir"].ToString());
                hc.ShowDialog();
      
                File.Delete(this.Context.Parameters["targetdir"] + "\\database.sql");
            }
        }
    }
      

  3.   

    好了,先结贴吧,我正在弄了,有了结果会在我的博客上写上的,欢迎大家来这里讨论,谢谢大家的参与http://www.cnblogs.com/virusswb/
      

  4.   

    顶了,我写了一篇关于这个内容的博客,欢迎大家来看,谢谢

    http://www.cnblogs.com/virusswb/archive/2008/07/09/1238819.html
      

  5.   

    this.Context.Parameters["targetdir"]
    你好
    这个属性什么啊,我是winform程序,想要在安装的过程修改appconfig文件的数据库连接配置,可是发现这个参数获取没有内容啊,就是那个用户界面的按装文件夹界面获取不到那个目录啊,就是我们安装程序选择的那个目录,本来应该是这个参数的,可是获取不到啊,如何获取呢这个软件就是授权才可以安装,这个好说,现在就是修改appconfig出了问题了,想在安装的过程修改appconfig,可是this.Context.Parameters["targetdir"]没有内容啊,