diff --git a/CleanFlashCommon/FileUtil.cs b/CleanFlashCommon/FileUtil.cs index 38b2a85..79f51e5 100644 --- a/CleanFlashCommon/FileUtil.cs +++ b/CleanFlashCommon/FileUtil.cs @@ -51,6 +51,10 @@ namespace CleanFlashCommon { return; } + if (file.Extension.ToLower().Equals(".ocx")) { + Uninstaller.UnregisterActiveX(file.FullName); + } + try { file.IsReadOnly = false; file.Delete(); diff --git a/CleanFlashCommon/Uninstaller.cs b/CleanFlashCommon/Uninstaller.cs index 41096a4..34d7013 100644 --- a/CleanFlashCommon/Uninstaller.cs +++ b/CleanFlashCommon/Uninstaller.cs @@ -27,6 +27,24 @@ namespace CleanFlashCommon { WinAPI.AllowModifications(); } + public static void UnregisterActiveX(string filename) { + string relativeFilename = Path.GetFileName(filename); + ProcessStartInfo info = new ProcessStartInfo { + FileName = "regsvr32.exe", + UseShellExecute = false, + CreateNoWindow = true + }; + + Directory.SetCurrentDirectory(Path.GetDirectoryName(filename)); + + info.Arguments = "/s /u " + relativeFilename; + ExitedProcess process = ProcessUtils.RunProcess(info); + + if (!process.IsSuccessful) { + throw new InstallException(string.Format("Failed to unregister ActiveX plugin: error code {0}\n\n{1}", process.ExitCode, process.Output)); + } + } + public static void UninstallRegistry() { if (Environment.Is64BitOperatingSystem) { RegistryManager.ApplyRegistry(Properties.Resources.uninstallRegistry, Properties.Resources.uninstallRegistry64);