From 07ad5774ec562d820ebe5a602ec260d74308c2d6 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Mon, 26 Oct 2015 18:51:03 +0200 Subject: [PATCH] Resolve shortcuts (*.lnk) in command line. --- od-win32/win32.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/od-win32/win32.cpp b/od-win32/win32.cpp index 5cd0c6ed..6a92b029 100644 --- a/od-win32/win32.cpp +++ b/od-win32/win32.cpp @@ -2529,7 +2529,6 @@ static int WIN32_InitLibraries (void) LARGE_INTEGER freq; SETCURRENTPROCESSEXPLICITAPPUSERMODEIDD pSetCurrentProcessExplicitAppUserModelID; - CoInitializeEx (NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); /* Determine our processor speed and capabilities */ if (!init_mmtimer ()) { pre_gui_message (_T("MMTimer initialization failed, exiting..")); @@ -5519,7 +5518,6 @@ static TCHAR **parseargstrings (TCHAR *s, TCHAR **xargv) return args; } - static int process_arg (TCHAR *cmdline, TCHAR **xargv, TCHAR ***xargv3) { int i, xargc; @@ -5535,6 +5533,21 @@ static int process_arg (TCHAR *cmdline, TCHAR **xargv, TCHAR ***xargv3) xargc = 0; xargv[xargc++] = my_strdup (_wpgmptr); fd = 0; + for (i = 0; argv[i]; i++) { + // resolve .lnk paths + const TCHAR *arg = argv[i]; + if (_tcslen(arg) > 4 && !_tcsicmp(arg + _tcslen(arg) - 4, _T(".lnk"))) { + if (my_existsfile(arg)) { + TCHAR s[MAX_DPATH]; + _tcscpy(s, arg); + if (my_resolveshortcut(s, MAX_DPATH)) { + xfree(argv[i]); + argv[i] = my_strdup(s); + } + } + } + } + for (i = 0; argv[i]; i++) { TCHAR *f = argv[i]; ok = 0; @@ -6560,6 +6573,7 @@ int PASCAL wWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdL currprefs.win32_filesystem_mangle_reserved_names = true; SetDllDirectory (_T("")); /* Make sure we do an InitCommonControls() to get some advanced controls */ + CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); InitCommonControls (); original_affinity = 1; -- 2.47.3