Implemented IExplorerCommand methods

This commit is contained in:
Ivan Stošić 2022-09-09 11:56:30 +02:00 committed by Ivan Stosic
parent 88aa85e365
commit f65958b212
4 changed files with 71 additions and 0 deletions

View File

@ -0,0 +1,10 @@
#pragma once
#include "pch.h"
// Localizable Constants, these should be converted to resources
namespace constants::localizable
{
// Text shown in the context menu
constexpr WCHAR CommandTitle[] = L"What's using this file?";
}

View File

@ -135,6 +135,7 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="Constants.h" />
<ClInclude Include="ExplorerCommand.h" />
<ClInclude Include="pch.h" />
</ItemGroup>

View File

@ -21,6 +21,9 @@
<ClInclude Include="ExplorerCommand.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Constants.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp">

View File

@ -1,6 +1,9 @@
#include "pch.h"
#include "ExplorerCommand.h"
#include "Constants.h"
// Implementations of inherited IUnknown methods
IFACEMETHODIMP ExplorerCommand::QueryInterface(REFIID riid, void** ppv)
{
@ -25,3 +28,57 @@ IFACEMETHODIMP_(ULONG) ExplorerCommand::Release()
}
return result;
}
// Implementations of inherited IExplorerCommand methods
IFACEMETHODIMP ExplorerCommand::GetTitle(IShellItemArray* psiItemArray, LPWSTR* ppszName)
{
return SHStrDup(constants::localizable::CommandTitle, ppszName);
}
IFACEMETHODIMP ExplorerCommand::GetIcon(IShellItemArray* psiItemArray, LPWSTR* ppszIcon)
{
// Path to the icon should be computed relative to the path of this module
ppszIcon = NULL;
return E_NOTIMPL;
}
IFACEMETHODIMP ExplorerCommand::GetToolTip(IShellItemArray* psiItemArray, LPWSTR* ppszInfotip)
{
// No tooltip for now
return E_NOTIMPL;
}
IFACEMETHODIMP ExplorerCommand::GetCanonicalName(GUID* pguidCommandName)
{
*pguidCommandName = __uuidof(this);
return S_OK;
}
IFACEMETHODIMP ExplorerCommand::GetState(IShellItemArray* psiItemArray, BOOL fOkToBeSlow, EXPCMDSTATE* pCmdState)
{
// This should depend on the settings
// For now we'll just keep it always enabled.
*pCmdState = ECS_ENABLED;
return S_OK;
}
IFACEMETHODIMP ExplorerCommand::Invoke(IShellItemArray* psiItemArray, IBindCtx* pbc)
{
// This should call the main exe.
// For now we'll just show a message box.
MessageBoxW(NULL, L"OK", L"OK", MB_OK);
return S_OK;
}
IFACEMETHODIMP ExplorerCommand::GetFlags(EXPCMDFLAGS* pFlags)
{
*pFlags = ECF_DEFAULT;
return S_OK;
}
IFACEMETHODIMP ExplorerCommand::EnumSubCommands(IEnumExplorerCommand** ppEnum)
{
*ppEnum = NULL;
return E_NOTIMPL;
}