LegacyUpdate/launcher/main.c

57 lines
1.1 KiB
C
Raw Normal View History

#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);
extern void RunOnce();
EXTERN_C __declspec(dllexport)
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow) {
g_hInstance = hInstance;
int argc;
2024-09-14 13:10:26 -04:00
LPWSTR *argv = CommandLineToArgvW(GetCommandLineW(), &argc);
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;
}
if (wcscmp(action, L"launch") == 0) {
2024-09-14 13:10:26 -04:00
LaunchUpdateSite(flagsCount, flags, nCmdShow);
} else if (wcscmp(action, L"/runonce") == 0) {
RunOnce();
} else {
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-14 13:10:26 -04:00
ExitProcess(msg.wParam);
return msg.wParam;
}