Author: akhaldi Date: Sun Feb 2 23:41:29 2014 New Revision: 61934
URL: http://svn.reactos.org/svn/reactos?rev=61934&view=rev Log: [SHELL32] * Fix how the shortcut targets are edited to allow for program arguments. * Brought to you by Huw Campbell. CORE-7763 #resolve #comment Committed in r61934. Thanks !
Modified: trunk/reactos/dll/win32/shell32/shelllink.cpp
Modified: trunk/reactos/dll/win32/shell32/shelllink.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/shelllink... ============================================================================== --- trunk/reactos/dll/win32/shell32/shelllink.cpp [iso-8859-1] (original) +++ trunk/reactos/dll/win32/shell32/shelllink.cpp [iso-8859-1] Sun Feb 2 23:41:29 2014 @@ -1955,8 +1955,20 @@
/* target path */ if (pThis->sPath) - SetDlgItemTextW(hwndDlg, 14009, pThis->sPath); - + { + WCHAR newpath[2*MAX_PATH] = L"\0"; + if (wcschr(pThis->sPath, ' ')) + StringCchPrintfExW(newpath, 2*MAX_PATH, NULL, NULL, 0, L""%ls"", pThis->sPath); + else + StringCchCopyExW(newpath, 2*MAX_PATH, pThis->sPath, NULL, NULL, 0); + + if (pThis->sArgs && pThis->sArgs[0]) + { + StringCchCatW(newpath, 2*MAX_PATH, L" "); + StringCchCatW(newpath, 2*MAX_PATH, pThis->sArgs); + } + SetDlgItemTextW(hwndDlg, 14009, newpath); + } /* working dir */ if (pThis->sWorkDir) SetDlgItemTextW(hwndDlg, 14011, pThis->sWorkDir); @@ -1973,21 +1985,25 @@ if (lppsn->hdr.code == PSN_APPLY) { WCHAR wszBuf[MAX_PATH]; - /* set working directory */ GetDlgItemTextW(hwndDlg, 14011, wszBuf, MAX_PATH); pThis->SetWorkingDirectory(wszBuf); /* set link destination */ GetDlgItemTextW(hwndDlg, 14009, wszBuf, MAX_PATH); - if (!PathFileExistsW(wszBuf)) + LPWSTR lpszArgs = NULL; + LPWSTR unquoted = strdupW(wszBuf); + StrTrimW(unquoted, L" "); + if (!PathFileExistsW(unquoted)) { - //FIXME load localized error msg - MessageBoxW(hwndDlg, L"file not existing", wszBuf, MB_OK); - SetWindowLongPtr(hwndDlg, DWL_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE); - return TRUE; + lpszArgs = PathGetArgsW(unquoted); + PathRemoveArgsW(unquoted); + StrTrimW(lpszArgs, L" "); } - - WCHAR *pwszExt = PathFindExtensionW(wszBuf); + if (unquoted[0] == '"' && unquoted[wcslen(unquoted)-1] == '"') + PathUnquoteSpacesW(unquoted); + + + WCHAR *pwszExt = PathFindExtensionW(unquoted); if (!wcsicmp(pwszExt, L".lnk")) { // FIXME load localized error msg @@ -1996,12 +2012,25 @@ return TRUE; }
- pThis->SetPath(wszBuf); + if (!PathFileExistsW(unquoted)) + { + //FIXME load localized error msg + MessageBoxW(hwndDlg, L"The specified file name in the target box is invalid", L"Error", MB_ICONERROR); + SetWindowLongPtr(hwndDlg, DWL_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE); + return TRUE; + } + + pThis->SetPath(unquoted); + if (lpszArgs) + pThis->SetArguments(lpszArgs); + else + pThis->SetArguments(L"\0"); + + HeapFree(GetProcessHeap(), 0, unquoted);
TRACE("This %p sLinkPath %S\n", pThis, pThis->sLinkPath); pThis->Save(pThis->sLinkPath, TRUE); - SetWindowLongPtr(hwndDlg, DWL_MSGRESULT, PSNRET_NOERROR); - return TRUE; + SetWindowLongPtr(hwndDlg, DWL_MSGRESULT, PSNRET_NOERROR); return TRUE; } break; }