-1

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.

Thanks in advance.

Kurubaran
  • 8,696
  • 5
  • 43
  • 65
Mogli
  • 1,972
  • 11
  • 34
  • 67

1 Answers1

0

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");
            }
        }
Community
  • 1
  • 1
Kurubaran
  • 8,696
  • 5
  • 43
  • 65