winapiwindows-10windows-10-desktopshell-extensionswindows-shell-extension-menu

Shortcut Menu with Dynamic Verbs for FILE_ATTRIBUTE_OFFLINE


I want that my Shortcut Menu via QueryContextMenu method (dynamic verbs), is visible as well for "Placeholders". Placeholders are Files that only exist locally virtual and needs to be downloaded from the cloud sync provider before the file can be read.

For this reason, I registered my Shortcut Menu via:

HKLM
{
    NoRemove Software
    {
        NoRemove Classes
        {
            NoRemove CLSID
            {
                ForceRemove '%CLSID%' = s '%DESCRIPTION%'
                {
                    InprocServer32 = s '%MODULE%'
                    {
                        val ThreadingModel = s 'Apartment'
                    }
                    SupportedProtocols = s '*'
                    {
                    }
                }
            }
            NoRemove AllSyncRootObjects
            {
                NoRemove ShellEx
                {
                    NoRemove ContextMenuHandlers
                    {
                        ForceRemove '%DESCRIPTION%' = s '%CLSID%'
                    }
                }
            }
        }
    }    
}

In case the file really exists locally, my context menu entries will be shown. But in case it was being dehydrated (converted to a Placeholder), my context menu entries will not be shown. How can I register my ShellExtension, so that it will be shown always? Which kind of flags do I need to set? Sadly the internet is saying nothing about it.

I tried to learn from the ClourMirror example of Microsoft, which provides custom context menu entries, but sadly they don't work: https://github.com/microsoft/Windows-classic-samples/issues/156 . At the same time, I tried to learn from the "Always keep on this device" and "free up space" context menu entries, which are registered with the flags SkipCloudDownload (value: 0) and StorageProviderFlagsRequired (value:2) and looks promising. Especially SkipCloudDownload, but I set this flag on various positions with no change.

In the current state of the project, dynamic verbs are required, because of cross-platform compatibility. Thx for any hint.


Solution

  • The solution is adding to the COM object the empty value 'ContextMenuOptIn':

    HKLM
    {
        NoRemove Software
        {
            NoRemove Classes
            {
                NoRemove CLSID
                {
                    ForceRemove '%CLSID%' = s '%DESCRIPTION%'
                    {
                        val ContextMenuOptIn= s ''
    
                        InprocServer32 = s '%MODULE%'
                        {
                            val ThreadingModel = s 'Apartment'
                        }
                    }
                }
                NoRemove AllSyncRootObjects
                {
                    NoRemove ShellEx
                    {
                        NoRemove ContextMenuHandlers
                        {
                            ForceRemove '%DESCRIPTION%' = s '%CLSID%'
                        }
                    }
                }
            }
        }    
    }
    

    I found the solution here: https://github.com/pipeline-foundation/projects/issues/97 They had several issues regarding the same problem and could fix it by adding the additional 'flag'.