[FileLocksmith] Fix issue causing explorer to crash (#27335)

Remove unneeded registry key
Align context menu handler logic with other modules
This commit is contained in:
Stefan Markovic 2023-07-12 12:24:58 +02:00 committed by GitHub
parent 4e9f4e57db
commit 9ad50161dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 26 deletions

View File

@ -26,9 +26,6 @@
</RegistryKey>
<RegistryKey Root="$(var.RegistryScope)" Key="Software\Classes\Drive\ShellEx\ContextMenuHandlers\FileLocksmithExt">
<RegistryValue Type="string" Value="{84D68575-E186-46AD-B0CB-BAEB45EE29C0}"/>
</RegistryKey>
<RegistryKey Root="$(var.RegistryScope)" Key="SOFTWARE\Classes\Directory\background\ShellEx\ContextMenuHandlers\FileLocksmithExt">
<RegistryValue Type="string" Value="{84D68575-E186-46AD-B0CB-BAEB45EE29C0}"/>
</RegistryKey>
</Component>
</DirectoryRef>

View File

@ -69,25 +69,7 @@ IFACEMETHODIMP ExplorerCommand::GetCanonicalName(GUID* pguidCommandName)
IFACEMETHODIMP ExplorerCommand::GetState(IShellItemArray* psiItemArray, BOOL fOkToBeSlow, EXPCMDSTATE* pCmdState)
{
if (!globals::enabled)
{
*pCmdState = ECS_HIDDEN;
}
if (FileLocksmithSettingsInstance().GetShowInExtendedContextMenu())
{
*pCmdState = ECS_HIDDEN;
return S_OK;
}
// When right clicking directory background, selection is empty.
if (nullptr == psiItemArray)
{
*pCmdState = ECS_HIDDEN;
return S_OK;
}
*pCmdState = ECS_ENABLED;
*pCmdState = FileLocksmithSettingsInstance().GetEnabled() ? ECS_ENABLED : ECS_HIDDEN;
return S_OK;
}
@ -112,9 +94,11 @@ IFACEMETHODIMP ExplorerCommand::EnumSubCommands(IEnumExplorerCommand** ppEnum)
IFACEMETHODIMP ExplorerCommand::Initialize(PCIDLIST_ABSOLUTE pidlFolder, IDataObject* pdtobj, HKEY hkeyProgID)
{
m_data_obj = NULL;
if (!FileLocksmithSettingsInstance().GetEnabled())
{
return S_OK;
return E_FAIL;
}
if (pdtobj)
@ -132,12 +116,12 @@ IFACEMETHODIMP ExplorerCommand::QueryContextMenu(HMENU hmenu, UINT indexMenu, UI
// Skip if disabled
if (!FileLocksmithSettingsInstance().GetEnabled())
{
return S_OK;
return E_FAIL;
}
if (FileLocksmithSettingsInstance().GetShowInExtendedContextMenu() && !(uFlags & CMF_EXTENDEDVERBS))
{
return S_OK;
return E_FAIL;
}
HRESULT hr = E_UNEXPECTED;

View File

@ -11,7 +11,6 @@ namespace globals
{
HMODULE instance;
std::atomic<ULONG> ref_count;
std::atomic<bool> enabled;
}
BOOL APIENTRY DllMain( HMODULE hModule,