المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Messagebox appearing behind uninstaller



C# Programming
11-26-2010, 07:23 PM
So I am trying to give the user an option of removing registry keys when uninstalling my application (the installer is the windows installer with visual studio).

The problem is it appears the message box appears behind the uninstaller (sometimes). Here is what I am doing:

public CustomInstaller() : base()
{
InitializeComponent();

base.AfterUninstall += new InstallEventHandler(CustomInstaller_AfterUninstall);
}

public override void Uninstall(IDictionary savedState)
{
base.Uninstall(savedState);
}

void CustomInstaller_AfterUninstall(object sender, InstallEventArgs e)
{
// Ask to remove settings
DialogResult result = MessageBox.Show("Do you want to remove all settings? (This is not reversible)", "Remove Settings",
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
try {
Registry.LocalMachine.DeleteSubKeyTree(@"Software\JD Development");
}
catch (Exception ex)
{
MessageBox.Show("Unable to remove registry settings: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

// Delete the service
Process.Start("sc", "delete JDAgent");
}