Showing custom form before installation?

ⅰ亾dé卋堺 提交于 2019-11-29 13:05:57
Kurubaran

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");
            }
        }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!