2024-09-06 06:10:19 -04:00
|
|
|
#include "stdafx.h"
|
|
|
|
#include "main.h"
|
|
|
|
#include "resource.h"
|
|
|
|
#include <windows.h>
|
|
|
|
#include <commctrl.h>
|
|
|
|
#include "MsgBox.h"
|
|
|
|
|
|
|
|
HINSTANCE g_hInstance;
|
|
|
|
|
2024-09-14 13:10:26 -04:00
|
|
|
extern void LaunchUpdateSite(int argc, LPWSTR *argv, int nCmdShow);
|
2024-09-06 06:10:19 -04:00
|
|
|
extern void RunOnce();
|
|
|
|
|
2024-09-11 04:28:57 -04:00
|
|
|
EXTERN_C __declspec(dllexport)
|
|
|
|
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow) {
|
2024-09-06 06:10:19 -04:00
|
|
|
g_hInstance = hInstance;
|
|
|
|
|
|
|
|
int argc;
|
2024-09-14 13:10:26 -04:00
|
|
|
LPWSTR *argv = CommandLineToArgvW(GetCommandLineW(), &argc);
|
2024-09-06 06:10:19 -04:00
|
|
|
|
|
|
|
LPWSTR action = L"launch";
|
|
|
|
if (argc > 1) {
|
|
|
|
action = argv[1];
|
|
|
|
}
|
|
|
|
|
2024-09-14 13:10:26 -04:00
|
|
|
// All remaining args past the action
|
|
|
|
LPWSTR *flags = {0};
|
|
|
|
int flagsCount = 0;
|
|
|
|
if (argc > 2) {
|
|
|
|
flags = &argv[2];
|
|
|
|
flagsCount = argc - 2;
|
|
|
|
}
|
|
|
|
|
2024-09-06 06:10:19 -04:00
|
|
|
if (wcscmp(action, L"launch") == 0) {
|
2024-09-14 13:10:26 -04:00
|
|
|
LaunchUpdateSite(flagsCount, flags, nCmdShow);
|
2024-09-06 06:10:19 -04:00
|
|
|
} else if (wcscmp(action, L"/runonce") == 0) {
|
|
|
|
RunOnce();
|
|
|
|
} else {
|
2024-09-11 04:28:57 -04:00
|
|
|
MsgBox(NULL, L"Unknown LegacyUpdate.exe usage", NULL, MB_OK);
|
2024-09-14 13:10:26 -04:00
|
|
|
PostQuitMessage(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
MSG msg;
|
|
|
|
while (GetMessage(&msg, NULL, 0, 0) == 1) {
|
|
|
|
TranslateMessage(&msg);
|
|
|
|
DispatchMessage(&msg);
|
|
|
|
|
|
|
|
switch (msg.message) {
|
|
|
|
case WM_QUIT:
|
|
|
|
case WM_DESTROY:
|
|
|
|
break;
|
|
|
|
}
|
2024-09-06 06:10:19 -04:00
|
|
|
}
|
|
|
|
|
2024-09-14 13:10:26 -04:00
|
|
|
ExitProcess(msg.wParam);
|
|
|
|
return msg.wParam;
|
2024-09-06 06:10:19 -04:00
|
|
|
}
|