mirror of
https://github.com/reactos/reactos.git
synced 2025-08-07 02:52:58 +00:00
[SHELL32] Don't add the file to the parameters if the registry command did not ask for a file (#7139)
Bugs fixed: - fDefault detection of default verb is flawed because it checks the ici struct after conversion instead of the source sei struct. - The command to execute should not have the filename appended just because %1 nor %L did not appear in the registry command template.
This commit is contained in:
parent
8f483a76a6
commit
724b20d414
5 changed files with 61 additions and 26 deletions
|
@ -1302,8 +1302,7 @@ CDefaultContextMenu::TryToBrowse(
|
|||
HRESULT
|
||||
CDefaultContextMenu::InvokePidl(LPCMINVOKECOMMANDINFOEX lpcmi, LPCITEMIDLIST pidl, PStaticShellEntry pEntry)
|
||||
{
|
||||
BOOL unicode = lpcmi->cbSize >= FIELD_OFFSET(CMINVOKECOMMANDINFOEX, ptInvoke) &&
|
||||
(lpcmi->fMask & CMIC_MASK_UNICODE);
|
||||
const BOOL unicode = IsUnicode(*lpcmi);
|
||||
|
||||
LPITEMIDLIST pidlFull = ILCombine(m_pidlFolder, pidl);
|
||||
if (pidlFull == NULL)
|
||||
|
@ -1315,7 +1314,23 @@ CDefaultContextMenu::InvokePidl(LPCMINVOKECOMMANDINFOEX lpcmi, LPCITEMIDLIST pid
|
|||
BOOL bHasPath = SHGetPathFromIDListW(pidlFull, wszPath);
|
||||
|
||||
WCHAR wszDir[MAX_PATH];
|
||||
if (bHasPath)
|
||||
|
||||
SHELLEXECUTEINFOW sei = { sizeof(sei) };
|
||||
sei.fMask = SEE_MASK_CLASSKEY | SEE_MASK_IDLIST | (CmicFlagsToSeeFlags(lpcmi->fMask) & ~SEE_MASK_INVOKEIDLIST);
|
||||
sei.hwnd = lpcmi->hwnd;
|
||||
sei.nShow = lpcmi->nShow;
|
||||
sei.lpVerb = pEntry->Verb;
|
||||
sei.lpIDList = pidlFull;
|
||||
sei.hkeyClass = pEntry->hkClass;
|
||||
sei.dwHotKey = lpcmi->dwHotKey;
|
||||
sei.hIcon = lpcmi->hIcon;
|
||||
sei.lpDirectory = wszDir;
|
||||
|
||||
if (unicode && !StrIsNullOrEmpty(lpcmi->lpDirectoryW))
|
||||
{
|
||||
sei.lpDirectory = lpcmi->lpDirectoryW;
|
||||
}
|
||||
else if (bHasPath)
|
||||
{
|
||||
wcscpy(wszDir, wszPath);
|
||||
PathRemoveFileSpec(wszDir);
|
||||
|
@ -1326,25 +1341,16 @@ CDefaultContextMenu::InvokePidl(LPCMINVOKECOMMANDINFOEX lpcmi, LPCITEMIDLIST pid
|
|||
*wszDir = UNICODE_NULL;
|
||||
}
|
||||
|
||||
CComHeapPtr<WCHAR> pszParamsW;
|
||||
SHELLEXECUTEINFOW sei = { sizeof(sei) };
|
||||
sei.hwnd = lpcmi->hwnd;
|
||||
sei.nShow = SW_SHOWNORMAL;
|
||||
sei.lpVerb = pEntry->Verb;
|
||||
sei.lpDirectory = wszDir;
|
||||
sei.lpIDList = pidlFull;
|
||||
sei.hkeyClass = pEntry->hkClass;
|
||||
sei.fMask = SEE_MASK_CLASSKEY | SEE_MASK_IDLIST;
|
||||
if (bHasPath)
|
||||
sei.lpFile = wszPath;
|
||||
|
||||
CComHeapPtr<WCHAR> pszParamsW;
|
||||
if (unicode && !StrIsNullOrEmpty(lpcmi->lpParametersW))
|
||||
sei.lpParameters = lpcmi->lpParametersW;
|
||||
else if (!StrIsNullOrEmpty(lpcmi->lpParameters) && __SHCloneStrAtoW(&pszParamsW, lpcmi->lpParameters))
|
||||
sei.lpParameters = pszParamsW;
|
||||
|
||||
ShellExecuteExW(&sei);
|
||||
|
||||
ILFree(pidlFull);
|
||||
|
||||
return S_OK;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue