mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-07 06:02:28 +02:00
Shut down interface when executing the Windows Launcher
This commit is contained in:
parent
00441f1899
commit
dcbb0f5db5
5 changed files with 34 additions and 12 deletions
|
@ -32,6 +32,11 @@ CLauncherApp theApp;
|
|||
// CLauncherApp initialization
|
||||
|
||||
BOOL CLauncherApp::InitInstance() {
|
||||
// Close interface if is running
|
||||
int interfacePID = -1;
|
||||
if (LauncherUtils::IsProcessRunning(L"interface.exe", interfacePID)) {
|
||||
LauncherUtils::shutdownProcess(interfacePID, 0);
|
||||
}
|
||||
int iNumOfArgs;
|
||||
LPWSTR* pArgs = CommandLineToArgvW(GetCommandLine(), &iNumOfArgs);
|
||||
bool isUninstalling = false;
|
||||
|
|
|
@ -629,7 +629,8 @@ void CLauncherDlg::OnTimer(UINT_PTR nIDEvent) {
|
|||
::SetForegroundWindow(_applicationWND);
|
||||
::SetActiveWindow(_applicationWND);
|
||||
}
|
||||
if (LauncherUtils::IsProcessRunning(L"interface.exe")) {
|
||||
int interfacePID = -1;
|
||||
if (LauncherUtils::IsProcessRunning(L"interface.exe", interfacePID)) {
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
@ -653,7 +654,8 @@ void CLauncherDlg::OnTimer(UINT_PTR nIDEvent) {
|
|||
}
|
||||
_splashStep++;
|
||||
} else if (theApp._manager.shouldShutDown()) {
|
||||
if (LauncherUtils::IsProcessRunning(L"interface.exe")) {
|
||||
int interfacePID = -1;
|
||||
if (LauncherUtils::IsProcessRunning(L"interface.exe", interfacePID)) {
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,13 +15,10 @@
|
|||
#include "LauncherManager.h"
|
||||
|
||||
|
||||
LauncherManager::LauncherManager()
|
||||
{
|
||||
LauncherManager::LauncherManager() {
|
||||
}
|
||||
|
||||
|
||||
LauncherManager::~LauncherManager()
|
||||
{
|
||||
LauncherManager::~LauncherManager() {
|
||||
}
|
||||
|
||||
void LauncherManager::init() {
|
||||
|
@ -113,8 +110,11 @@ BOOL LauncherManager::installLauncher() {
|
|||
// The installer is not running on the desired location and has to be installed
|
||||
// Kill of running before self-copy
|
||||
addToLog(_T("Installing Launcher."));
|
||||
if (LauncherUtils::IsProcessRunning(LAUNCHER_EXE_FILENAME)) {
|
||||
ShellExecute(NULL, NULL, L"taskkill", L"/F /T /IM " + LAUNCHER_EXE_FILENAME, NULL, SW_HIDE);
|
||||
int launcherPID = -1;
|
||||
if (LauncherUtils::IsProcessRunning(LAUNCHER_EXE_FILENAME, launcherPID)) {
|
||||
if (!LauncherUtils::shutdownProcess(launcherPID, 0)) {
|
||||
addToLog(_T("Error shutting down the Launcher"));
|
||||
}
|
||||
}
|
||||
CopyFile(appPath, instalationPath, FALSE);
|
||||
}
|
||||
|
@ -308,7 +308,8 @@ LauncherUtils::ResponseError LauncherManager::readConfigJSON(CString& version, C
|
|||
}
|
||||
Json::Value config;
|
||||
configFile >> config;
|
||||
if (config["version"].isString() && config["domain"].isString() &&
|
||||
if (config["version"].isString() &&
|
||||
config["domain"].isString() &&
|
||||
config["content"].isString()) {
|
||||
loggedIn = config["loggedIn"].asBool();
|
||||
version = config["version"].asCString();
|
||||
|
|
|
@ -37,7 +37,19 @@ CString LauncherUtils::urlEncodeString(const CString& url) {
|
|||
return stringOut;
|
||||
}
|
||||
|
||||
BOOL LauncherUtils::IsProcessRunning(const wchar_t *processName) {
|
||||
BOOL LauncherUtils::shutdownProcess(DWORD dwProcessId, UINT uExitCode) {
|
||||
DWORD dwDesiredAccess = PROCESS_TERMINATE;
|
||||
BOOL bInheritHandle = FALSE;
|
||||
HANDLE hProcess = OpenProcess(dwDesiredAccess, bInheritHandle, dwProcessId);
|
||||
if (hProcess == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
BOOL result = TerminateProcess(hProcess, uExitCode);
|
||||
CloseHandle(hProcess);
|
||||
return result;
|
||||
}
|
||||
|
||||
BOOL LauncherUtils::IsProcessRunning(const wchar_t *processName, int& processID) {
|
||||
bool exists = false;
|
||||
PROCESSENTRY32 entry;
|
||||
entry.dwSize = sizeof(PROCESSENTRY32);
|
||||
|
@ -48,6 +60,7 @@ BOOL LauncherUtils::IsProcessRunning(const wchar_t *processName) {
|
|||
while (Process32Next(snapshot, &entry)) {
|
||||
if (!_wcsicmp(entry.szExeFile, processName)) {
|
||||
exists = true;
|
||||
processID = entry.th32ProcessID;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,7 +73,8 @@ public:
|
|||
static std::string cStringToStd(CString cstring);
|
||||
static BOOL getFont(const CString& fontName, int fontSize, bool isBold, CFont& fontOut);
|
||||
static BOOL launchApplication(LPCWSTR lpApplicationName, LPTSTR cmdArgs = _T(""));
|
||||
static BOOL IsProcessRunning(const wchar_t *processName);
|
||||
static BOOL IsProcessRunning(const wchar_t *processName, int& processID);
|
||||
static BOOL shutdownProcess(DWORD dwProcessId, UINT uExitCode);
|
||||
static BOOL insertRegistryKey(const std::string& regPath, const std::string& name, const std::string& value);
|
||||
static BOOL insertRegistryKey(const std::string& regPath, const std::string& name, DWORD value);
|
||||
static BOOL deleteFileOrDirectory(const CString& dirPath, bool noRecycleBin = true);
|
||||
|
|
Loading…
Reference in a new issue