[PATCH v2] shell32: Implement SHCreateItemInKnownFolder.

Jactry Zeng jactry92 at gmail.com
Tue Aug 8 02:06:58 CDT 2017


Hi Huw,

SHCreateItemInKnownFolder() isn't available on WinXP and 2003 too.
I sent another try which loading SHGetKnownFolderPath() dynamically.

Thanks for review!

2017-08-07 18:33 GMT+08:00 Huw Davies <huw at codeweavers.com>:

> On Fri, Aug 04, 2017 at 02:54:15PM +0800, Jactry Zeng wrote:
> > diff --git a/dlls/shell32/tests/shlfolder.c b/dlls/shell32/tests/
> shlfolder.c
> > index 9e7127dfea..b77619d428 100644
> > --- a/dlls/shell32/tests/shlfolder.c
> > +++ b/dlls/shell32/tests/shlfolder.c
> > @@ -2519,6 +2521,120 @@ static void test_SHCreateShellItem(void)
> >      else
> >          win_skip("No SHCreateItemFromIDList\n");
> >
> > +    /* SHCreateItemInKnownFolder */
> > +    if(pSHCreateItemInKnownFolder)
> > +    {
> > +        WCHAR *desktop_path;
> > +        WCHAR testfile_path[MAX_PATH] = {0};
> > +        HANDLE file;
> > +        WCHAR *displayname = NULL;
> > +        int order;
> > +        LPITEMIDLIST pidl_desktop_testfile = NULL;
> > +
> > +        if(0)
> > +        {
> > +            /* crashes on Windows */
> > +            pSHCreateItemInKnownFolder(NULL, 0, NULL, NULL, NULL);
> > +            pSHCreateItemInKnownFolder(&FOLDERID_Desktop, 0, NULL,
> NULL, NULL);
> > +            pSHCreateItemInKnownFolder(&FOLDERID_Desktop, 0,
> testfileW, &IID_IShellItem, NULL);
> > +        }
> > +
> > +        shellitem = (void*)0xdeadbeef;
> > +        ret = pSHCreateItemInKnownFolder(&FOLDERID_Desktop, 0, NULL,
> &IID_IShellItem,
> > +                                         (void**)&shellitem);
> > +        ok(ret == S_OK, "SHCreateItemInKnownFolder failed: 0x%08x.\n",
> ret);
> > +        ok(shellitem != NULL, "shellitem was %p.\n", shellitem);
> > +        if(SUCCEEDED(ret))
> > +        {
> > +            shellitem2 = (void*)0xdeadbeef;
> > +            ret = pSHCreateShellItem(NULL, NULL, pidl_desktop,
> &shellitem2);
> > +            ok(SUCCEEDED(ret), "SHCreateShellItem returned %x\n", ret);
> > +            if(SUCCEEDED(ret))
> > +            {
> > +                ret = IShellItem_Compare(shellitem, shellitem2, 0,
> &order);
> > +                ok(ret == S_OK, "IShellItem_Compare failed: 0x%08x\n",
> ret);
> > +                ok(!order, "order got wrong value: %d\n", order);
> > +                IShellItem_Release(shellitem2);
> > +            }
> > +            IShellItem_Release(shellitem);
> > +        }
> > +
> > +        /* Test with a non-existent file */
> > +        shellitem = (void*)0xdeadbeef;
> > +        ret = pSHCreateItemInKnownFolder(&FOLDERID_Desktop, 0,
> testfileW, &IID_IShellItem,
> > +                                         (void**)&shellitem);
> > +        ok(ret == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "Expected
> 0x%08x but SHCreateItemInKnownFolder return: 0x%08x.\n",
> > +           HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), ret);
> > +        ok(shellitem == NULL, "shellitem was %p.\n", shellitem);
> > +
> > +        SHGetKnownFolderPath(&FOLDERID_Desktop, 0, NULL,
> &desktop_path);
>
> It looks like SHGetKnownFolderPath is not available on WinXP, so
> you'll have to load it dynamically.  OTOH I think
> SHCreateItemInKnownFolder()
> is available on all the platforms that we care about, so you can static
> link
> to that one.
>
> Huw.
>
>
>


-- 
Regards,
Jactry Zeng
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20170808/2e5a3a43/attachment.html>


More information about the wine-devel mailing list