public override void Uninstall(IDictionary savedState)
{
base.Uninstall(savedState);
// BDS 13-11-2006
// Instead of simply restoring the originalPathRegValue stored during the
// installation now we read the installDir from the state saver and
// replace it in the PATH stored in the registry. This will not damage
// the other entries in the PATH variable.
string origRegValue = (string)savedState["OriginalPathRegValue"];
string installDir = (string)savedState["InstallDir"];
RegistryHelper registry = new RegistryHelper();
registry.BaseRegistryKey = Registry.LocalMachine;
registry.SubKey += @"System\CurrentControlSet\Control\Session Manager\Environment";
string currentPath = registry.ReadKey("PATH");
if (currentPath != null && currentPath.Length > 0)
{
if (installDir != null && installDir.Length > 0)
{
registry.WriteKey("PATH", currentPath.Replace(";" + installDir, ""));
}
}
EnvironmentHelper.BroadCast();
try
{
// Remove the registry entry.
Registry.LocalMachine.DeleteSubKey(RegistrySubKey, false);
// Remove the .addin file.
string addinFile = (string)savedState[@"AddinFilePath"];
if (addinFile != null && File.Exists(addinFile))
{
File.Delete(addinFile);
}
}
catch (SecurityException)
{
MessageBox.Show(@"You must have write permission to the HKEY_LOCAL_MACHINE registry key in order to uninstall this software.");
throw new InstallException(@"Access denied.");
}
catch
{
throw new InstallException(@"Unknown error.");
}
}