Showing custom form before installation?

后端 未结 1 490
梦谈多话
梦谈多话 2020-12-20 10:33

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

相关标签:
1条回答
  • 2020-12-20 11:14

    Following would be the easiest approach,

    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.

    Installer classe's 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");
                }
            }
    
    0 讨论(0)
提交回复
热议问题