mirror of
https://github.com/reactos/reactos.git
synced 2024-11-23 03:23:34 +08:00
[SHELL32][BROWSEUI] Set DefView InvokeCommand directory (#7495)
If a .lnk shortcut does not specify a working directory, it should use the directory provided by the InvokeCommand caller when it's launced. CORE-19855
This commit is contained in:
parent
3ecd2363a6
commit
a17b6e9369
@ -937,6 +937,22 @@ STDMETHODIMP CFindFolder::MessageSFVCB(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
CComVariant searchBar(pwszGuid);
|
||||
return pWebBrowser2->ShowBrowserBar(&searchBar, NULL, NULL);
|
||||
}
|
||||
case SFVM_GETCOMMANDDIR:
|
||||
{
|
||||
HRESULT hr = E_FAIL;
|
||||
if (m_shellFolderView)
|
||||
{
|
||||
PCUITEMID_CHILD *apidl;
|
||||
UINT cidl = 0;
|
||||
if (SUCCEEDED(hr = m_shellFolderView->GetSelectedObjects(&apidl, &cidl)))
|
||||
{
|
||||
if (cidl)
|
||||
hr = StringCchCopyW((PWSTR)lParam, wParam, _ILGetPath(apidl[0]));
|
||||
LocalFree(apidl);
|
||||
}
|
||||
}
|
||||
return hr;
|
||||
}
|
||||
}
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
@ -2623,6 +2623,7 @@ HRESULT STDMETHODCALLTYPE CShellLink::InvokeCommand(LPCMINVOKECOMMANDINFO lpici)
|
||||
|
||||
HRESULT CShellLink::DoOpen(LPCMINVOKECOMMANDINFO lpici)
|
||||
{
|
||||
LPCMINVOKECOMMANDINFOEX iciex = (LPCMINVOKECOMMANDINFOEX)lpici;
|
||||
const BOOL unicode = IsUnicode(*lpici);
|
||||
|
||||
CStringW args;
|
||||
@ -2631,7 +2632,6 @@ HRESULT CShellLink::DoOpen(LPCMINVOKECOMMANDINFO lpici)
|
||||
|
||||
if (unicode)
|
||||
{
|
||||
LPCMINVOKECOMMANDINFOEX iciex = (LPCMINVOKECOMMANDINFOEX)lpici;
|
||||
if (!StrIsNullOrEmpty(iciex->lpParametersW))
|
||||
{
|
||||
args += L' ';
|
||||
@ -2674,6 +2674,15 @@ HRESULT CShellLink::DoOpen(LPCMINVOKECOMMANDINFO lpici)
|
||||
if (lpici->nShow != SW_SHOWNORMAL && lpici->nShow != SW_SHOW)
|
||||
sei.nShow = lpici->nShow; // Allow invoker to override .lnk show mode
|
||||
|
||||
// Use the invoker specified working directory if the link did not specify one
|
||||
if (StrIsNullOrEmpty(sei.lpDirectory) || !PathIsDirectoryW(sei.lpDirectory))
|
||||
{
|
||||
LPCSTR pszDirA = lpici->lpDirectory;
|
||||
if (unicode && !StrIsNullOrEmpty(iciex->lpDirectoryW))
|
||||
sei.lpDirectory = iciex->lpDirectoryW;
|
||||
else if (pszDirA && SHAnsiToUnicode(pszDirA, dir, _countof(dir)))
|
||||
sei.lpDirectory = dir;
|
||||
}
|
||||
return (ShellExecuteExW(&sei) ? S_OK : E_FAIL);
|
||||
}
|
||||
|
||||
|
@ -1069,6 +1069,13 @@ HRESULT WINAPI CDesktopFolderViewCB::MessageSFVCB(UINT uMsg, WPARAM wParam, LPAR
|
||||
case SFVM_VIEWRELEASE:
|
||||
m_pShellView = NULL;
|
||||
return S_OK;
|
||||
case SFVM_GETCOMMANDDIR:
|
||||
{
|
||||
WCHAR buf[MAX_PATH];
|
||||
if (SHGetSpecialFolderPathW(NULL, buf, CSIDL_DESKTOPDIRECTORY, TRUE))
|
||||
return StringCchCopyW((PWSTR)lParam, wParam, buf);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
@ -2076,6 +2076,10 @@ HRESULT WINAPI CFSFolder::MessageSFVCB(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
case SFVM_GET_CUSTOMVIEWINFO:
|
||||
hr = GetCustomViewInfo((ULONG)wParam, (SFVM_CUSTOMVIEWINFO_DATA *)lParam);
|
||||
break;
|
||||
case SFVM_GETCOMMANDDIR:
|
||||
if (m_sPathTarget)
|
||||
hr = StringCchCopyW((PWSTR)lParam, wParam, m_sPathTarget);
|
||||
break;
|
||||
}
|
||||
return hr;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user