mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-08-07 09:01:38 -04:00
Windows: Fix calibre portable launcher not working correctly from root directory in calibre 5.5. Fixes #1904310 [v5.5 Puts calibre-portable.exe in as a book on every launch](https://bugs.launchpad.net/calibre/+bug/1904310)
apparently, the cmdline parameter passed to winmain does not contain the path to the EXE *except* when the exe is in the root folder. The number of inconsistencies in the win32 API is insane.
This commit is contained in:
parent
fbbb8ffdf5
commit
4b0f19ccfb
@ -222,15 +222,14 @@ wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR orig_cmd_line, int
|
||||
config_dir.append(application_dir); config_dir.append(L"Calibre Settings");
|
||||
exe.append(application_dir); exe.append(L"Calibre\\"); exe.append(exe_name);
|
||||
|
||||
// Note that orig_cmd_line does not have argv[0] as the executable name
|
||||
int argc;
|
||||
wchar_t **argv = CommandLineToArgvW(orig_cmd_line, &argc);
|
||||
wchar_t **argv = CommandLineToArgvW(GetCommandLineW(), &argc);
|
||||
if (argv == NULL) {
|
||||
show_last_error(L"Failed to convert cmdline to argv array");
|
||||
return 1;
|
||||
}
|
||||
quote_argv(exe, cmd_line);
|
||||
for (int i = 0; i < argc; i++) {
|
||||
for (int i = 1; i < argc; i++) {
|
||||
std::wstring arg(argv[i]);
|
||||
cmd_line.push_back(L' ');
|
||||
quote_argv(arg, cmd_line);
|
||||
|
Loading…
x
Reference in New Issue
Block a user