[PATCH 2/5] shell32: Use SHCreateDefaultContextMenu to create context menus (try 2)

Nikolay Sivov nsivov at codeweavers.com
Mon Aug 22 03:21:01 CDT 2011


On 8/21/2011 19:20, Jay Yang wrote:
> Changes from last time:
>
> Factored out the code to find the registry keys for the extensions.
>
> ---
>   dlls/shell32/classes.c        |   47 +++++++++++++++++++++++++++++++++++++++++
>   dlls/shell32/shell32_main.h   |    1 +
>   dlls/shell32/shfldr.h         |    9 +++++++
>   dlls/shell32/shfldr_desktop.c |    8 ++----
>   dlls/shell32/shfldr_fs.c      |    7 +----
>   dlls/shell32/shfldr_mycomp.c  |    4 +--
>   dlls/shell32/shfldr_unixfs.c  |   11 ++++++---
>   dlls/shell32/shlmenu.c        |   40 ++++++++++++++++++++++++++++++++++
>   dlls/shell32/shlview.c        |   44 +++++++++++++++++++++++++-------------
>   9 files changed, 139 insertions(+), 32 deletions(-)
> +HRESULT SHELL_CreateItemContextMenu(HWND hwnd, IShellFolder *folder,
> +                                    LPITEMIDLIST folder_pidl,
> +                                    LPCITEMIDLIST *apidl, UINT cidl,
> +                                    REFIID riid, void **ppv)
> +{
> +    DEFCONTEXTMENU menu_info = {hwnd,NULL,folder_pidl,folder,cidl,apidl,NULL,0,NULL};
> +    UINT cKeys = 0;
> +    HKEY aKeys[16] = {NULL};
Where size of 16 comes from?
> +    UINT i;
> +    HRESULT hres;
> +    cKeys = HCR_GetExtensionsKeysForPidl(apidl[0],aKeys);
> +    menu_info.cKeys=cKeys;
> +    menu_info.aKeys=aKeys;
> +    hres = SHCreateDefaultContextMenu(&menu_info,riid,ppv);
> +    for(i=0;i<cKeys;i++)
> +        if(aKeys[i])
> +            RegCloseKey(aKeys[i]);
RegCloseKey already check for NULL handle.

> +        hr = IShellFolder_CreateViewObject(This->pSFParent,This->hWndParent,&IID_IContextMenu,(void**)&pCM);
> +        if(FAILED(hr)){
> +            LPITEMIDLIST folder_pidl;
> +            IPersistFolder2 *persist;
> +            IShellFolder_QueryInterface(This->pSFParent,&IID_IPersistFolder2,(void**)&persist);
> +            IPersistFolder2_GetCurFolder(persist,&folder_pidl);
> +            IPersistFolder2_Release(persist);
> +            hr= SHELL_CreateBackgroundContextMenu(This->hWndParent,This->pSFParent,
> +                                                  folder_pidl,&IID_IContextMenu,
> +                                                  (void**)&pCM);
> +            ILFree(folder_pidl);
> +        }
I'm not sure about that, but it looks like it deserves some check for 
'persist' pointer. Or better a return value being S_OK (from query).




More information about the wine-devel mailing list