2019-10-18 11:57:19 +08:00
|
|
|
#pragma once
|
|
|
|
#include "stdafx.h"
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
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 DWORD WINAPI s_PowerRenameUIThreadProc(_In_ void* pData);
|
|
|
|
|
|
|
|
static bool SetEnabled(_In_ bool enabled);
|
|
|
|
static bool IsEnabled();
|
|
|
|
|
|
|
|
private:
|
2020-01-15 07:23:21 +08:00
|
|
|
~CPowerRenameMenu(){
|
|
|
|
delete (app_name);
|
|
|
|
}
|
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-15 07:23:21 +08:00
|
|
|
wchar_t* app_name;
|
2019-10-18 11:57:19 +08:00
|
|
|
};
|