mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-11-24 04:12:32 +08:00
[FileLocksmith]Fix triggering FileLocksmith unexpectedly through verbs (#34905)
This commit is contained in:
parent
cc586a0357
commit
c890eb95ca
@ -166,51 +166,58 @@ IFACEMETHODIMP ExplorerCommand::QueryContextMenu(HMENU hmenu, UINT indexMenu, UI
|
||||
|
||||
IFACEMETHODIMP ExplorerCommand::InvokeCommand(CMINVOKECOMMANDINFO* pici)
|
||||
{
|
||||
Trace::Invoked();
|
||||
ipc::Writer writer;
|
||||
HRESULT hr = E_FAIL;
|
||||
|
||||
if (HRESULT result = writer.start(); FAILED(result))
|
||||
if (FileLocksmithSettingsInstance().GetEnabled() &&
|
||||
pici && (IS_INTRESOURCE(pici->lpVerb)) &&
|
||||
(LOWORD(pici->lpVerb) == 0))
|
||||
{
|
||||
Trace::InvokedRet(result);
|
||||
return result;
|
||||
}
|
||||
Trace::Invoked();
|
||||
ipc::Writer writer;
|
||||
|
||||
if (HRESULT result = LaunchUI(pici, &writer); FAILED(result))
|
||||
{
|
||||
Trace::InvokedRet(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
IShellItemArray* shell_item_array;
|
||||
HRESULT result = SHCreateShellItemArrayFromDataObject(m_data_obj, __uuidof(IShellItemArray), reinterpret_cast<void**>(&shell_item_array));
|
||||
if (SUCCEEDED(result))
|
||||
{
|
||||
DWORD num_items;
|
||||
shell_item_array->GetCount(&num_items);
|
||||
for (DWORD i = 0; i < num_items; i++)
|
||||
if (HRESULT result = writer.start(); FAILED(result))
|
||||
{
|
||||
IShellItem* item;
|
||||
result = shell_item_array->GetItemAt(i, &item);
|
||||
if (SUCCEEDED(result))
|
||||
{
|
||||
LPWSTR file_path;
|
||||
result = item->GetDisplayName(SIGDN_FILESYSPATH, &file_path);
|
||||
if (SUCCEEDED(result))
|
||||
{
|
||||
// TODO Aggregate items and send to UI
|
||||
writer.add_path(file_path);
|
||||
CoTaskMemFree(file_path);
|
||||
}
|
||||
|
||||
item->Release();
|
||||
}
|
||||
Trace::InvokedRet(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
shell_item_array->Release();
|
||||
if (HRESULT result = LaunchUI(pici, &writer); FAILED(result))
|
||||
{
|
||||
Trace::InvokedRet(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
IShellItemArray* shell_item_array;
|
||||
hr = SHCreateShellItemArrayFromDataObject(m_data_obj, __uuidof(IShellItemArray), reinterpret_cast<void**>(&shell_item_array));
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
DWORD num_items;
|
||||
shell_item_array->GetCount(&num_items);
|
||||
for (DWORD i = 0; i < num_items; i++)
|
||||
{
|
||||
IShellItem* item;
|
||||
hr = shell_item_array->GetItemAt(i, &item);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
LPWSTR file_path;
|
||||
hr = item->GetDisplayName(SIGDN_FILESYSPATH, &file_path);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
// TODO Aggregate items and send to UI
|
||||
writer.add_path(file_path);
|
||||
CoTaskMemFree(file_path);
|
||||
}
|
||||
|
||||
item->Release();
|
||||
}
|
||||
}
|
||||
|
||||
shell_item_array->Release();
|
||||
}
|
||||
}
|
||||
|
||||
Trace::InvokedRet(S_OK);
|
||||
return S_OK;
|
||||
Trace::InvokedRet(hr);
|
||||
return hr;
|
||||
}
|
||||
|
||||
IFACEMETHODIMP ExplorerCommand::GetCommandString(UINT_PTR idCmd, UINT uType, UINT* pReserved, CHAR* pszName, UINT cchMax)
|
||||
|
Loading…
Reference in New Issue
Block a user