我打算在做安装程序中加一个输入序列号的页面,判断如果输入错误,就不让它安装下去了。怎么做也不行!
using System;
using System.Collections;
using System.Collections.Generic;
using
using System.Configuration.Install;
using System.Linq;
namespace WebSetupConponent
{
[RunInstaller(true)]
public partial class Installer1 : Installer
{
public Installer1()
{
InitializeComponent();
this.BeforeInstall += new InstallEventHandler(Installer1_BeforeInstall);
this.AfterInstall += new InstallEventHandler(Installer1_AfterInstall);
+= new InstallEventHandler(Installer1_Committing);
+= new InstallEventHandler(Installer1_Committed);
this.BeforeUninstall += new InstallEventHandler(Installer1_BeforeUninstall);
this.AfterUninstall += new InstallEventHandler(Installer1_AfterUninstall);
}
private void Installer1_BeforeInstall(object sender, InstallEventArgs e)
{
}
private void Installer1_AfterInstall(object sender, InstallEventArgs e)
{
Form1 _FC = new Form1();
_FC.ShowDialog();
if (_FC.DialogResult == System.Windows.Forms.DialogResult.OK)
{
//继续安装程序
}
else
{
//退出安装程序
}
}
private void Installer1_Committing(object sender, InstallEventArgs e)
{
}
private void Installer1_Committed(object sender, InstallEventArgs e)
{
}
private void Installer1_BeforeUninstall(object sender, InstallEventArgs e)
{
}
private void Installer1_AfterUninstall(object sender, InstallEventArgs e)
{
}
protected override void OnAfterInstall(IDictionary savedState)
{
Form1 _FC = new Form1();
_FC.ShowDialog();
if (_FC.DialogResult == System.Windows.Forms.DialogResult.OK)
{
base.OnAfterInstall(savedState);
}
else
{
//base.Uninstall(savedState); 发生错误
//base.Rollback(savedState);
发生错误
}
}
public override void Install(IDictionary stateSaver)
{
base.Install(stateSaver);
}
protected override void OnBeforeInstall(IDictionary savedState)
{
Form1 _FC = new Form1();
_FC.ShowDialog();
if (_FC.DialogResult == System.Windows.Forms.DialogResult.OK)
{
base.OnBeforeInstall(savedState);
}
else
{
//base.Uninstall(savedState);
发生错误
//base.Rollback(savedState);
发生错误
}
}
public override void Uninstall(IDictionary savedState)
{
base.Uninstall(savedState);
}
public override void Rollback(IDictionary savedState)
{
base.Rollback(savedState);
}
}
}