在安装前显示自定义表格? [英] Showing custom form before installation?

查看:76
本文介绍了在安装前显示自定义表格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为Windows应用程序创建一个安装程序,我想在用户单击安装程序时显示一个表单。该表格将要求用户输入密码。

I am creating a setup for windows application, i want to show a form when user clicks on setup. That form will ask for password to the user.

正确的密码将导致安装程序的正确安装,否则将取消安装程序。

Right password will lead to the proper installation of the setup otherwise setup installation will be cancelled.

如果有人提供链接的话,该怎么做。

How to do this, if some one provide a link for it.

预先感谢。

推荐答案

以下将是最简单的方法,

Following would be the easiest approach,


  1. 首先创建一个 Windows窗体,该窗体允许用户输入密码。

  2. Windows窗体应具有验证所需的实现。

  3. 在Windows窗体中暴露一个公共布尔属性,该属性应说明密码是否有效。

  4. 现在您必须添加一个新的类库项目添加到您的解决方案中(或使用现有项目)。

  5. 添加安装程序类到新项目。

  6. 安装程序类的安装方法,您必须打开创建的Windows窗体(请注意,在此处不能以模态弹出窗口的形式打开 )。

  7. 现在的窗口表单将获取用户输入并对其进行验证,并将布尔值设置为适当的布尔值

  8. 在基于布尔值的安装程序类中,您将继续安装或中止安装。

  1. First create a Windows Form which allows the user to enter password.
  2. Windows Form should have the necessary implementation to validate the password.
  3. Expose a public boolean property within windows form which should say whether password it valid or not.
  4. Now you have to add a new class library project to your solution(or you an use existing project).
  5. Add a Installer Class to your new project.
  6. Within installer class's Install method you have to open created windows form (please note windows form can not be opened as a modal pop up here).
  7. Now windows form will get user input and validate it and set the boolean value to puplic property.
  8. Within installer class based on the boolean value you will either continue the installation or abort.

安装程序类的Install()

public override void Install(System.Collections.IDictionary stateSaver)
        {
            base.Install(stateSaver);

            Form1 validationForm = new Form1();
            validationForm.ShowDialog();

            if (!validationForm.IsValidPassword)
            {
                throw new Exception("Invalid Password. Please enter valid password to continue installation");
            }
        }

这篇关于在安装前显示自定义表格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆