mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-03 09:46:54 +02:00
[PowerRename] Add PowerRename to directory background context menu (#24522)
* Add PowerRename to directory background context menu * Fix analyzer error * Add more checks
This commit is contained in:
@@ -46,14 +46,26 @@ HRESULT CPowerRenameMenu::s_CreateInstance(_In_opt_ IUnknown*, _In_ REFIID riid,
|
||||
}
|
||||
|
||||
// IShellExtInit
|
||||
HRESULT CPowerRenameMenu::Initialize(_In_opt_ PCIDLIST_ABSOLUTE, _In_ IDataObject* pdtobj, HKEY)
|
||||
HRESULT CPowerRenameMenu::Initialize(_In_opt_ PCIDLIST_ABSOLUTE idlist, _In_ IDataObject* pdtobj, HKEY)
|
||||
{
|
||||
// Check if we have disabled ourselves
|
||||
if (!CSettingsInstance().GetEnabled())
|
||||
return E_FAIL;
|
||||
|
||||
// Cache the data object to be used later
|
||||
m_spdo = pdtobj;
|
||||
if (idlist != NULL)
|
||||
{
|
||||
CComPtr<IShellItemArray> spsia;
|
||||
if (SUCCEEDED(SHCreateShellItemArrayFromIDLists(1, &idlist, &spsia)) && spsia != NULL)
|
||||
{
|
||||
spsia->BindToHandler(NULL, BHID_DataObject, IID_IDataObject, reinterpret_cast<void**>(&m_spdo));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_spdo = pdtobj;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -124,7 +136,7 @@ HRESULT CPowerRenameMenu::RunPowerRename(CMINVOKECOMMANDINFO* pici, IShellItemAr
|
||||
HRESULT hr = E_FAIL;
|
||||
|
||||
if (CSettingsInstance().GetEnabled() &&
|
||||
(IS_INTRESOURCE(pici->lpVerb)) &&
|
||||
pici && (IS_INTRESOURCE(pici->lpVerb)) &&
|
||||
(LOWORD(pici->lpVerb) == 0))
|
||||
{
|
||||
Trace::Invoked();
|
||||
@@ -163,14 +175,7 @@ HRESULT CPowerRenameMenu::RunPowerRename(CMINVOKECOMMANDINFO* pici, IShellItemAr
|
||||
startupInfo.cb = sizeof(STARTUPINFO);
|
||||
startupInfo.hStdInput = hReadPipe;
|
||||
startupInfo.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
|
||||
if (pici)
|
||||
{
|
||||
startupInfo.wShowWindow = static_cast<WORD>(pici->nShow);
|
||||
}
|
||||
else
|
||||
{
|
||||
startupInfo.wShowWindow = SW_SHOWNORMAL;
|
||||
}
|
||||
startupInfo.wShowWindow = static_cast<WORD>(pici->nShow);
|
||||
|
||||
PROCESS_INFORMATION processInformation;
|
||||
|
||||
@@ -201,15 +206,18 @@ HRESULT CPowerRenameMenu::RunPowerRename(CMINVOKECOMMANDINFO* pici, IShellItemAr
|
||||
// psiItemArray is NULL if called from InvokeCommand. This part is used for the MSI installer. It is not NULL if it is called from Invoke (MSIX).
|
||||
if (!psiItemArray)
|
||||
{
|
||||
// Stream the input files
|
||||
HDropIterator i(m_spdo);
|
||||
for (i.First(); !i.IsDone(); i.Next())
|
||||
if (m_spdo)
|
||||
{
|
||||
CString fileName(i.CurrentItem());
|
||||
// File name can't contain '?'
|
||||
fileName.Append(_T("?"));
|
||||
// Stream the input files
|
||||
HDropIterator i(m_spdo);
|
||||
for (i.First(); !i.IsDone(); i.Next())
|
||||
{
|
||||
CString fileName(i.CurrentItem());
|
||||
// File name can't contain '?'
|
||||
fileName.Append(_T("?"));
|
||||
|
||||
writePipe.Write(fileName, fileName.GetLength() * sizeof(TCHAR));
|
||||
writePipe.Write(fileName, fileName.GetLength() * sizeof(TCHAR));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user