SHInvokeCommandWithFlagsAndSite

Go to Home Page

Invokes a verb on a context menu

Syntax

HRESULT WINAPI SHInvokeCommandWithFlagsAndSite (
    HWND hwnd,
    IObjectWithSite* pSite,
    IShellFolder* pShellFolder,
    LPITEMIDLIST pidl,
    DWORD fMask,
    LPCSTR pszVerb
)

Parameters

hwnd
The owner window for any UI
pSite
A site to host the context menu, can be NULL.
pShellFolder
A pointer to an IShellFolder interface containing pidl
pidl
A pidl representing an item in pShellFolder to get the context menu of
fMask
A collection of CMIC_ flags to pass onto the CMINVOKECOMANDINFO structure used with pCtxMenu->InvokeCommand()
pszVerb
A verb to invoke on the context menu. Can be NULL.

Return Value

S_OK on success, standard COM error code on failure

Remarks

This function is functionally identical to the following:

HRESULT WINAPI SHInvokeCommandWithFlagsAndSite(
    HWND hwnd, 
    IObjectWithSite* pSite,
    IShellFolder* pShellFolder,
    LPITEMIDLIST pidl,
    DWORD fMask,
    LPCSTR pszVerb
)
{
    HRESULT hr = S_OK;
    IContextMenu* pMenu = NULL;
    if(SUCCEEDED(hr = pShellFolder->GetUIObjectOf(hwnd, 1, &pidl, IID_IContextMenu, NULL, (PVOID*)&pMenu)))
    {
        hr = SHInvokeCommandOnContextMenuEx(hwnd, pSite, pMenu, fMask, 0, pszVerb, NULL);
        pMenu->Release();
    }
    return hr;
}

The remarks for the fMask parameter and other shared parameters with SHInvokeCommandsOnContextMenuEx apply here.

This function is also known as _SHInvokeCommandOnContextMenuEx@28.