2019-10-18 11:57:19 +08:00
|
|
|
#pragma once
|
2020-04-30 04:02:18 +08:00
|
|
|
#include "pch.h"
|
2019-10-18 11:57:19 +08:00
|
|
|
|
2019-12-19 17:15:54 +08:00
|
|
|
class __declspec(uuid("0440049F-D1DC-4E46-B27B-98393D79486B")) CPowerRenameMenu :
|
2019-10-18 11:57:19 +08:00
|
|
|
public IShellExtInit,
|
2019-12-19 17:15:54 +08:00
|
|
|
public IContextMenu,
|
|
|
|
public IExplorerCommand
|
2019-10-18 11:57:19 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
CPowerRenameMenu();
|
|
|
|
|
|
|
|
// IUnknown
|
|
|
|
IFACEMETHODIMP QueryInterface(_In_ REFIID riid, _COM_Outptr_ void** ppv)
|
|
|
|
{
|
2019-12-20 21:59:20 +08:00
|
|
|
static const QITAB qit[] = {
|
2019-10-18 11:57:19 +08:00
|
|
|
QITABENT(CPowerRenameMenu, IShellExtInit),
|
|
|
|
QITABENT(CPowerRenameMenu, IContextMenu),
|
2019-12-19 17:15:54 +08:00
|
|
|
QITABENT(CPowerRenameMenu, IExplorerCommand),
|
2019-10-18 11:57:19 +08:00
|
|
|
{ 0, 0 },
|
|
|
|
};
|
|
|
|
return QISearch(this, qit, riid, ppv);
|
|
|
|
}
|
|
|
|
|
2019-12-20 21:59:20 +08:00
|
|
|
IFACEMETHODIMP_(ULONG)
|
|
|
|
AddRef()
|
2019-10-18 11:57:19 +08:00
|
|
|
{
|
2019-12-19 17:15:54 +08:00
|
|
|
return ++m_refCount;
|
2019-10-18 11:57:19 +08:00
|
|
|
}
|
|
|
|
|
2019-12-20 21:59:20 +08:00
|
|
|
IFACEMETHODIMP_(ULONG)
|
|
|
|
Release()
|
2019-10-18 11:57:19 +08:00
|
|
|
{
|
2019-12-19 17:15:54 +08:00
|
|
|
LONG refCount = --m_refCount;
|
2019-10-18 11:57:19 +08:00
|
|
|
if (refCount == 0)
|
|
|
|
{
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
return refCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
// IShellExtInit
|
|
|
|
STDMETHODIMP Initialize(_In_opt_ PCIDLIST_ABSOLUTE pidlFolder, _In_ IDataObject* pdto, HKEY hkProgID);
|
|
|
|
|
|
|
|
// IContextMenu
|
|
|
|
STDMETHODIMP QueryContextMenu(HMENU hMenu, UINT index, UINT uIDFirst, UINT uIDLast, UINT uFlags);
|
|
|
|
STDMETHODIMP InvokeCommand(_In_ LPCMINVOKECOMMANDINFO pCMI);
|
|
|
|
STDMETHODIMP GetCommandString(UINT_PTR, UINT, _In_opt_ UINT*, _In_ LPSTR, UINT)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2021-10-25 21:40:19 +08:00
|
|
|
HRESULT RunPowerRename(CMINVOKECOMMANDINFO* pici, IShellItemArray* psiItemArray);
|
|
|
|
|
2019-12-19 17:15:54 +08:00
|
|
|
// Inherited via IExplorerCommand
|
|
|
|
virtual HRESULT __stdcall GetTitle(IShellItemArray* psiItemArray, LPWSTR* ppszName) override;
|
|
|
|
virtual HRESULT __stdcall GetIcon(IShellItemArray* psiItemArray, LPWSTR* ppszIcon) override;
|
|
|
|
virtual HRESULT __stdcall GetToolTip(IShellItemArray* psiItemArray, LPWSTR* ppszInfotip) override;
|
|
|
|
virtual HRESULT __stdcall GetCanonicalName(GUID* pguidCommandName) override;
|
|
|
|
virtual HRESULT __stdcall GetState(IShellItemArray* psiItemArray, BOOL fOkToBeSlow, EXPCMDSTATE* pCmdState) override;
|
|
|
|
virtual HRESULT __stdcall Invoke(IShellItemArray* psiItemArray, IBindCtx* pbc) override;
|
|
|
|
virtual HRESULT __stdcall GetFlags(EXPCMDFLAGS* pFlags) override;
|
|
|
|
virtual HRESULT __stdcall EnumSubCommands(IEnumExplorerCommand** ppEnum) override;
|
|
|
|
|
2019-10-18 11:57:19 +08:00
|
|
|
static HRESULT s_CreateInstance(_In_opt_ IUnknown* punkOuter, _In_ REFIID riid, _Outptr_ void** ppv);
|
|
|
|
|
|
|
|
static bool SetEnabled(_In_ bool enabled);
|
|
|
|
static bool IsEnabled();
|
|
|
|
|
|
|
|
private:
|
2020-01-16 05:57:05 +08:00
|
|
|
~CPowerRenameMenu();
|
2019-10-18 11:57:19 +08:00
|
|
|
|
2019-12-19 17:15:54 +08:00
|
|
|
std::atomic<long> m_refCount = 1;
|
|
|
|
HBITMAP m_hbmpIcon = nullptr;
|
2019-10-18 11:57:19 +08:00
|
|
|
CComPtr<IDataObject> m_spdo;
|
2020-01-18 03:06:57 +08:00
|
|
|
std::wstring app_name;
|
2019-10-18 11:57:19 +08:00
|
|
|
};
|