| 39 | EXTERN_C __declspec(dllexport) |
| 40 | #endif |
| 41 | int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow) { |
| 42 | g_hInstance = hInstance; |
| 43 | Startup(); |
| 44 | OpenLog(); |
| 45 | |
| 46 | // nCmdShow seems to give us garbage values. Get it from the startup info struct. |
| 47 | STARTUPINFO startupInfo; |
| 48 | GetStartupInfo(&startupInfo); |
| 49 | nCmdShow = (startupInfo.dwFlags & STARTF_USESHOWWINDOW) ? startupInfo.wShowWindow : SW_SHOWDEFAULT; |
| 50 | |
| 51 | // Init COM |
| 52 | HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); |
| 53 | CHECK_HR_OR_GOTO_END(L"CoInitializeEx"); |
| 54 | |
| 55 | // Init common controls |
| 56 | INITCOMMONCONTROLSEX initComctl = {0}; |
| 57 | initComctl.dwSize = sizeof(initComctl); |
| 58 | initComctl.dwICC = ICC_WIN95_CLASSES; |
| 59 | InitCommonControlsEx(&initComctl); |
| 60 | |
| 61 | int argc; |
| 62 | LPWSTR *argv = CommandLineToArgvW(GetCommandLineW(), &argc); |
| 63 | |
| 64 | LPWSTR actionFlag = L"/launch"; |
| 65 | if (argc > 1) { |
| 66 | actionFlag = argv[1]; |
| 67 | } |
| 68 | |
| 69 | // All remaining args past the action |
| 70 | LPWSTR *flags = NULL; |
| 71 | int flagsCount = 0; |
| 72 | if (argc > 2) { |
| 73 | flags = &argv[2]; |
| 74 | flagsCount = argc - 2; |
| 75 | } |
| 76 | |
| 77 | Action action = -1; |
| 78 | |
| 79 | for (DWORD i = 0; i < ARRAYSIZE(actions); i++) { |
| 80 | if (wcscmp(actionFlag, actions[i]) == 0) { |
| 81 | action = i; |
| 82 | break; |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | switch (action) { |
| 87 | case ActionLaunch: |
| 88 | LaunchUpdateSite(flagsCount, flags, nCmdShow); |
| 89 | break; |
| 90 | |
| 91 | case ActionOptions: |
| 92 | LaunchOptions(nCmdShow); |
| 93 | break; |
| 94 | |
| 95 | case ActionLog: |
| 96 | LaunchLog(flagsCount, flags, nCmdShow); |
| 97 | break; |
| 98 |
nothing calls this directly
no test coverage detected