Portable Installer: Do not ask to launch calibre when running an automated install. Automated installs will now never launch calibre.

This commit is contained in:
Kovid Goyal 2016-03-05 10:10:23 +05:30
parent a619ed9ce4
commit 974722696b

View File

@ -504,20 +504,20 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine
LPVOID cdata = NULL; LPVOID cdata = NULL;
DWORD csz = 0; DWORD csz = 0;
int ret = 0, argc; int ret = 1, argc;
HRESULT hr; HRESULT hr;
LPWSTR tgt = NULL, dest = NULL, *argv, unpack_dir = NULL; LPWSTR tgt = NULL, dest = NULL, *argv, unpack_dir = NULL;
BOOL existing = false, launch = false, automated = false; BOOL existing = false, launch = false, automated = false;
WCHAR buf[4*MAX_PATH] = {0}, mb_msg[4*MAX_PATH] = {0}, fdest[4*MAX_PATH] = {0}; WCHAR buf[4*MAX_PATH] = {0}, mb_msg[4*MAX_PATH] = {0}, fdest[4*MAX_PATH] = {0};
if (!load_data(&cdata, &csz)) return 0; if (!load_data(&cdata, &csz)) return ret;
hr = CoInitialize(NULL); hr = CoInitialize(NULL);
if (FAILED(hr)) { show_error(L"Failed to initialize COM"); return 0; } if (FAILED(hr)) { show_error(L"Failed to initialize COM"); return ret; }
// Get the target directory for installation // Get the target directory for installation
argv = CommandLineToArgvW(GetCommandLine(), &argc); argv = CommandLineToArgvW(GetCommandLine(), &argc);
if (argv == NULL) { show_last_error(L"Failed to get command line"); return 0; } if (argv == NULL) { show_last_error(L"Failed to get command line"); return ret; }
if (argc > 1) { if (argc > 1) {
tgt = argv[1]; tgt = argv[1];
automated = true; automated = true;
@ -578,17 +578,20 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine
// Move files from temp dir to the install dir // Move files from temp dir to the install dir
if (!move_program()) goto end; if (!move_program()) goto end;
ret = 0;
if (!automated) {
_snwprintf_s(mb_msg, 4*MAX_PATH, _TRUNCATE, _snwprintf_s(mb_msg, 4*MAX_PATH, _TRUNCATE,
L"Calibre Portable successfully installed to %s. Launch calibre?", L"Calibre Portable successfully installed to %s. Launch calibre?",
fdest); fdest);
launch = MessageBox(NULL, mb_msg, launch = MessageBox(NULL, mb_msg,
L"Success", MB_ICONINFORMATION | MB_YESNO | MB_TOPMOST) == IDYES; L"Success", MB_ICONINFORMATION | MB_YESNO | MB_TOPMOST) == IDYES;
}
end: end:
if (unpack_dir != NULL) { SetCurrentDirectoryW(L".."); rmtree(unpack_dir); free(unpack_dir); } if (unpack_dir != NULL) { SetCurrentDirectoryW(L".."); rmtree(unpack_dir); free(unpack_dir); }
CoUninitialize(); CoUninitialize();
if (launch) launch_calibre(); if (launch) launch_calibre();
return 0; return ret;
} }