mirror of
https://github.com/reactos/reactos.git
synced 2025-04-20 04:20:46 +00:00
[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 ! svn path=/trunk/; revision=61934
This commit is contained in:
parent
f7c21a892e
commit
7eb7ed4823
1 changed files with 41 additions and 12 deletions
|
@ -1955,8 +1955,20 @@ INT_PTR CALLBACK CShellLink::SH_ShellLinkDlgProc(HWND hwndDlg, UINT uMsg, WPARAM
|
|||
|
||||
/* 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 @@ INT_PTR CALLBACK CShellLink::SH_ShellLinkDlgProc(HWND hwndDlg, UINT uMsg, WPARAM
|
|||
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" ");
|
||||
}
|
||||
if (unquoted[0] == '"' && unquoted[wcslen(unquoted)-1] == '"')
|
||||
PathUnquoteSpacesW(unquoted);
|
||||
|
||||
WCHAR *pwszExt = PathFindExtensionW(wszBuf);
|
||||
|
||||
WCHAR *pwszExt = PathFindExtensionW(unquoted);
|
||||
if (!wcsicmp(pwszExt, L".lnk"))
|
||||
{
|
||||
// FIXME load localized error msg
|
||||
|
@ -1996,12 +2012,25 @@ INT_PTR CALLBACK CShellLink::SH_ShellLinkDlgProc(HWND hwndDlg, UINT uMsg, WPARAM
|
|||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue