static void Main() { //string resource1 = "MyApp.System.Windows.Forms.Ribbon35.dll"; //string resource2 = "MyApp.System.Data.SQLite.dll"; //EmbeddedAssembly.Load(resource1, "System.Windows.Forms.Ribbon35.dll"); //EmbeddedAssembly.Load(resource2, "System.Data.SQLite.dll"); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); try { var clickOnceHelper = new ClickOnceHelper(Globals.PublisherName, Globals.ProductName); clickOnceHelper.UpdateUninstallParameters(); clickOnceHelper.AddShortcutToStartup(); UpdateDownloadCount(); } catch (Exception ex) { Debug.WriteLine(ex); } //To Run the application as administrator if (!IsRunAsAdministrator()) { // It is not possible to launch a ClickOnce app as administrator directly, so instead we launch the // app as administrator in a new process. var processInfo = new ProcessStartInfo(Assembly.GetExecutingAssembly().CodeBase); // The following properties run the new process as administrator processInfo.UseShellExecute = true; processInfo.Verb = "runas"; // Start the new process try { Process.Start(processInfo); } catch (Exception) { // The user did not allow the application to run as administrator GearHeadMessageBox.Instance.Show("Sorry, this application must be run as Administrator.", ConfigSettings.ClientName, MessageBoxButtons.OK, MessageBoxIcon.Information); } // Shut down the current process Environment.Exit(0); } else { //Starting Up Bandwidth Monitor startMonitor(); Application.Run(new MainWindow(strVersion)); } //Application.Run(new MainWindow()); }
{ var clickOnceHelper = new ClickOnceHelper(Globals.PublisherName, Globals.ProductName); clickOnceHelper.UpdateUninstallParameters(); clickOnceHelper.AddShortcutToStartup(); } catch (Exception ex) { Debug.WriteLine(ex); } base.OnStartup(e); } } }
static void Main() { try { bool createdNew; instanceMutex = new Mutex(true, @"Local\" + Assembly.GetExecutingAssembly().GetType().GUID, out createdNew); if (!createdNew) { instanceMutex = null; return; } if (MessageBox.Show(Resources.Uninstall_Question, Resources.Uninstall + Globals.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes) { var clickOnceHelper = new ClickOnceHelper(Globals.PublisherName, Globals.ProductName); clickOnceHelper.Uninstall(); //Delete all files from publisher folder and folder itself on uninstall var publisherFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), Globals.PublisherName); if (Directory.Exists(publisherFolder)) Directory.Delete(publisherFolder, true); } ReleaseMutex(); } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
static void Main() { try { bool createdNew; instanceMutex = new Mutex(true, @"Local\" + Assembly.GetExecutingAssembly().GetType().GUID, out createdNew); if (!createdNew) { instanceMutex = null; return; } if (GearHeadMessageBox.Instance.Show(Resources.Uninstall_Question, Resources.Uninstall + Globals.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Warning, GearHeadMessageBox.ModuleEnum.Uninstall) == DialogResult.Yes) { UpdateUnistallStatus(); stopClamVirusService(); var clickOnceHelper = new ClickOnceHelper(Globals.PublisherName, Globals.ProductName); clickOnceHelper.Uninstall(); //Delete all files from publisher folder and folder itself on uninstall var publisherFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), Globals.PublisherName); if (Directory.Exists(publisherFolder)) Directory.Delete(publisherFolder, true); if (Directory.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), Globals.ProductName))) { try { Directory.Delete(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), Globals.ProductName), true); } catch (Exception) { } } if (Directory.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "ErrorLog"))) { try { Directory.Delete((Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "ErrorLog")), true); } catch (Exception) { } } } ReleaseMutex(); } catch (Exception ex) { Debug.WriteLine(ex.Message); } }