-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #80 from matanki-saito/develop
Develop
- Loading branch information
Showing
6 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#include "moddl.h" | ||
|
||
bool createProcess(WCHAR* szCmd, DWORD flag) { | ||
STARTUPINFO si; | ||
PROCESS_INFORMATION pi; | ||
WCHAR *message = L"Autoupdate error. Please DELETE 'claes.exe'."; | ||
WCHAR *title = NULL; | ||
|
||
memset(&si, 0, sizeof(STARTUPINFO)); | ||
memset(&pi, 0, sizeof(PROCESS_INFORMATION)); | ||
si.cb = sizeof(STARTUPINFO); | ||
|
||
BOOL createProcessSuccess = CreateProcess(NULL, szCmd, NULL, NULL, FALSE, flag, NULL, NULL, &si, &pi); | ||
|
||
if (!createProcessSuccess) { | ||
title = L"Autoupdate createProcess failed."; | ||
} | ||
else { | ||
DWORD result = WaitForSingleObject(pi.hProcess, 35 * 1000); // 35 sec | ||
switch (result) | ||
{ | ||
case WAIT_FAILED: | ||
title = L"moddownload wait failed."; | ||
break; | ||
case WAIT_TIMEOUT: | ||
title = L"moddownload wait timeout."; | ||
break; | ||
default: | ||
break; | ||
} | ||
CloseHandle(pi.hProcess); | ||
CloseHandle(pi.hThread); | ||
|
||
if (title != NULL) { | ||
MessageBox(NULL, message, title, MB_OK); | ||
return false; | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
|
||
bool InitAutoUpdate(const path &pluginsPath) | ||
{ | ||
path exeFilePath = path{ pluginsPath } / L"claes.exe"; | ||
|
||
if (std::experimental::filesystem::exists(exeFilePath)) { | ||
return createProcess( | ||
wcsdup(exeFilePath.c_str()), | ||
CREATE_NO_WINDOW | ||
); | ||
} | ||
|
||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#pragma once | ||
|
||
#include <windows.h> | ||
#include <conio.h> | ||
#include <stdio.h> | ||
#include <filesystem> | ||
|
||
using namespace std; | ||
using namespace std::experimental::filesystem::v1; | ||
|
||
bool InitAutoUpdate(const path &folder); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters