Re: shell32: Implement SHCreateItemInKnownFolder.
On Sun, Jul 30, 2017 at 05:37:02PM +0800, Jactry Zeng wrote:
diff --git a/dlls/shell32/shellitem.c b/dlls/shell32/shellitem.c index 1e19f7c72e..57fb849f16 100644 --- a/dlls/shell32/shellitem.c +++ b/dlls/shell32/shellitem.c @@ -662,6 +662,66 @@ HRESULT WINAPI SHCreateItemFromIDList(PCIDLIST_ABSOLUTE pidl, REFIID riid, void return ret; }
+HRESULT WINAPI SHCreateItemInKnownFolder(REFKNOWNFOLDERID rfid, DWORD flags, + LPWSTR filename, REFIID riid, void **ppv) +{ + HRESULT hr; + WCHAR *pathW = NULL; + IShellFolder *desktop = NULL, *folder = NULL; + LPITEMIDLIST pidl_folder = NULL, pidl = NULL; + + TRACE("%p, %x, %s, %s, %p\n", rfid, flags, wine_dbgstr_w(filename), + debugstr_guid(riid), ppv); + + if(!rfid || !ppv) + return E_INVALIDARG; + + if(flags) + FIXME("flags 0x%08x not supported\n", flags); + + *ppv = NULL; + hr = SHGetDesktopFolder(&desktop); + if(hr != S_OK) return hr; + + hr = SHGetKnownFolderPath(rfid, 0, NULL, &pathW); + if(hr != S_OK) return hr; + + hr = IShellFolder_ParseDisplayName(desktop, NULL, NULL, pathW, NULL, &pidl_folder, NULL); + if(hr != S_OK) + goto cleanup;
You probably want to use SHGetKnownFolderIDList() instead of these last two calls. Huw.
Hi Huw, Thanks for review! 2017-07-31 15:47 GMT+08:00 Huw Davies <huw(a)codeweavers.com>:
You probably want to use SHGetKnownFolderIDList() instead of these last two calls.
I had some more tests of SHGetKnownFolderIDList() and IShellFolder_BindToObject(), I found that in some cases SHGetKnownFolderIDList() will return a pidl which ILIsEmpty() thinks it is empty. And IShellFolder_BindToObject() will return E_INVALIDARG for an empty pidl. So keep using SHGetKnownFolderPath() and IShellFolder_ParseDisplayName() seems can make this work more easy? -- Regards, Jactry Zeng
On Wed, Aug 02, 2017 at 10:58:34AM +0800, Jactry Zeng wrote:
2017-07-31 15:47 GMT+08:00 Huw Davies <huw(a)codeweavers.com>:
You probably want to use SHGetKnownFolderIDList() instead of these last two calls.
I had some more tests of SHGetKnownFolderIDList() and IShellFolder_BindToObject (), I found that in some cases SHGetKnownFolderIDList() will return a pidl which ILIsEmpty() thinks it is empty.
This is presumably a bug in SHGetKnownFolderIDList(), which we should fix. Huw.
2017-08-02 16:04 GMT+08:00 Huw Davies <huw(a)codeweavers.com>:
This is presumably a bug in SHGetKnownFolderIDList(), which we should fix.
Yes, there is a bug in SHGetKnownFolderIDList(), but I find it will not hinder implementing SHCreateItemInKnownFolder(). I will send tests and possible fix for SHGetKnownFolderIDList() later. Thanks! -- Regards, Jactry Zeng
participants (2)
-
Huw Davies -
Jactry Zeng