add check if application is running
This commit is contained in:
parent
bcf11b4d79
commit
802b2daaaf
2 changed files with 19 additions and 6 deletions
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Shapes;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Text.RegularExpressions;
|
||||
|
@ -26,6 +25,11 @@ namespace EnvyUpdate
|
|||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
if (Util.IsProcessOpen("EnvyUpdate"))
|
||||
{
|
||||
MessageBox.Show("Application is already running.");
|
||||
System.Environment.Exit(1);
|
||||
}
|
||||
if (!Directory.Exists(appdata))
|
||||
{
|
||||
Directory.CreateDirectory(appdata);
|
||||
|
@ -39,7 +43,7 @@ namespace EnvyUpdate
|
|||
else
|
||||
{
|
||||
MessageBox.Show("No NVIDIA GPU found. Application will exit.");
|
||||
System.Windows.Application.Current.Shutdown();
|
||||
System.Environment.Exit(255);
|
||||
}
|
||||
if (File.Exists(appdata + "nvidia-update.txt"))
|
||||
{
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Management;
|
||||
using System.Net;
|
||||
using System.IO;
|
||||
using IWshRuntimeLibrary;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace EnvyUpdate
|
||||
{
|
||||
|
@ -86,5 +83,17 @@ namespace EnvyUpdate
|
|||
shortcut.TargetPath = targetFileLocation;
|
||||
shortcut.Save();
|
||||
}
|
||||
public static bool IsProcessOpen(string name)
|
||||
{
|
||||
foreach (Process clsProcess in Process.GetProcesses())
|
||||
{
|
||||
if (clsProcess.ProcessName.Contains(name))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue