[PATCH 1/5] shell32: Move SHCreateShellFolderView/SHCreateShellFolderViewEx and tests to corresponding files

Nikolay Sivov nsivov at codeweavers.com
Sun Apr 30 14:01:53 CDT 2017


Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
 dlls/shell32/shellord.c        |  70 -----------------------
 dlls/shell32/shlview.c         |  59 ++++++++++++++++++++
 dlls/shell32/tests/shlfolder.c | 123 -----------------------------------------
 dlls/shell32/tests/shlview.c   | 122 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 181 insertions(+), 193 deletions(-)

diff --git a/dlls/shell32/shellord.c b/dlls/shell32/shellord.c
index 96dd33aa30..f9814997da 100644
--- a/dlls/shell32/shellord.c
+++ b/dlls/shell32/shellord.c
@@ -1086,40 +1086,6 @@ void WINAPI SHAddToRecentDocs (UINT uFlags,LPCVOID pv)
 }
 
 /*************************************************************************
- * SHCreateShellFolderViewEx			[SHELL32.174]
- *
- * Create a new instance of the default Shell folder view object.
- *
- * RETURNS
- *  Success: S_OK
- *  Failure: error value
- *
- * NOTES
- *  see IShellFolder::CreateViewObject
- */
-HRESULT WINAPI SHCreateShellFolderViewEx(
-	LPCSFV psvcbi,    /* [in] shelltemplate struct */
-	IShellView **ppv) /* [out] IShellView pointer */
-{
-	IShellView * psf;
-	HRESULT hRes;
-
-	TRACE("sf=%p pidl=%p cb=%p mode=0x%08x parm=%p\n",
-	  psvcbi->pshf, psvcbi->pidl, psvcbi->pfnCallback,
-	  psvcbi->fvm, psvcbi->psvOuter);
-
-	*ppv = NULL;
-	psf = IShellView_Constructor(psvcbi->pshf);
-
-	if (!psf)
-	  return E_OUTOFMEMORY;
-
-	hRes = IShellView_QueryInterface(psf, &IID_IShellView, (LPVOID *)ppv);
-	IShellView_Release(psf);
-
-	return hRes;
-}
-/*************************************************************************
  *  SHWinHelp					[SHELL32.127]
  *
  */
@@ -2195,39 +2161,3 @@ HRESULT WINAPI SHGetImageList(int iImageList, REFIID riid, void **ppv)
 
     return HIMAGELIST_QueryInterface(hNew, riid, ppv);
 }
-
-/*************************************************************************
- * SHCreateShellFolderView			[SHELL32.256]
- *
- * Create a new instance of the default Shell folder view object.
- *
- * RETURNS
- *  Success: S_OK
- *  Failure: error value
- *
- * NOTES
- *  see IShellFolder::CreateViewObject
- */
-HRESULT WINAPI SHCreateShellFolderView(const SFV_CREATE *pcsfv,
-                        IShellView **ppsv)
-{
-	IShellView * psf;
-	HRESULT hRes;
-
-	*ppsv = NULL;
-	if (!pcsfv || pcsfv->cbSize != sizeof(*pcsfv))
-	  return E_INVALIDARG;
-
-	TRACE("sf=%p outer=%p callback=%p\n",
-	  pcsfv->pshf, pcsfv->psvOuter, pcsfv->psfvcb);
-
-	psf = IShellView_Constructor(pcsfv->pshf);
-
-	if (!psf)
-	  return E_OUTOFMEMORY;
-
-	hRes = IShellView_QueryInterface(psf, &IID_IShellView, (LPVOID *)ppsv);
-	IShellView_Release(psf);
-
-	return hRes;
-}
diff --git a/dlls/shell32/shlview.c b/dlls/shell32/shlview.c
index 92eda5579a..070f0705cb 100644
--- a/dlls/shell32/shlview.c
+++ b/dlls/shell32/shlview.c
@@ -3744,3 +3744,62 @@ IShellView *IShellView_Constructor(IShellFolder *folder)
     TRACE("(%p)->(%p)\n", sv, folder);
     return (IShellView*)&sv->IShellView3_iface;
 }
+
+/*************************************************************************
+ * SHCreateShellFolderView			[SHELL32.256]
+ *
+ * Create a new instance of the default Shell folder view object.
+ *
+ * RETURNS
+ *  Success: S_OK
+ *  Failure: error value
+ *
+ * NOTES
+ *  see IShellFolder::CreateViewObject
+ */
+HRESULT WINAPI SHCreateShellFolderView(const SFV_CREATE *desc, IShellView **shellview)
+{
+    TRACE("(%p, %p)\n", desc, shellview);
+
+    *shellview = NULL;
+
+    if (!desc || desc->cbSize != sizeof(*desc))
+        return E_INVALIDARG;
+
+    TRACE("sf=%p outer=%p callback=%p\n", desc->pshf, desc->psvOuter, desc->psfvcb);
+
+    if (!desc->pshf)
+        return E_UNEXPECTED;
+
+    *shellview = IShellView_Constructor(desc->pshf);
+    if (!*shellview)
+        return E_OUTOFMEMORY;
+
+    return S_OK;
+}
+
+/*************************************************************************
+ * SHCreateShellFolderViewEx			[SHELL32.174]
+ *
+ * Create a new instance of the default Shell folder view object.
+ *
+ * RETURNS
+ *  Success: S_OK
+ *  Failure: error value
+ *
+ * NOTES
+ *  see IShellFolder::CreateViewObject
+ */
+HRESULT WINAPI SHCreateShellFolderViewEx(CSFV *desc, IShellView **shellview)
+{
+    TRACE("(%p, %p)\n", desc, shellview);
+
+    TRACE("sf=%p pidl=%p cb=%p mode=0x%08x parm=%p\n", desc->pshf, desc->pidl, desc->pfnCallback,
+        desc->fvm, desc->psvOuter);
+
+    *shellview = IShellView_Constructor(desc->pshf);
+    if (!*shellview)
+        return E_OUTOFMEMORY;
+
+    return S_OK;
+}
diff --git a/dlls/shell32/tests/shlfolder.c b/dlls/shell32/tests/shlfolder.c
index 9b0e7a78cf..9e7127dfea 100644
--- a/dlls/shell32/tests/shlfolder.c
+++ b/dlls/shell32/tests/shlfolder.c
@@ -73,8 +73,6 @@ static HRESULT (WINAPI *pSHGetItemFromObject)(IUnknown*,REFIID,void**);
 static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL);
 static UINT (WINAPI *pGetSystemWow64DirectoryW)(LPWSTR, UINT);
 static HRESULT (WINAPI *pSHCreateDefaultContextMenu)(const DEFCONTEXTMENU*,REFIID,void**);
-static HRESULT (WINAPI *pSHCreateShellFolderView)(const SFV_CREATE *pcsfv, IShellView **ppsv);
-static HRESULT (WINAPI *pSHCreateShellFolderViewEx)(LPCSFV psvcbi, IShellView **ppv);
 static HRESULT (WINAPI *pSHILCreateFromPath)(LPCWSTR, LPITEMIDLIST *,DWORD*);
 static BOOL (WINAPI *pSHGetPathFromIDListEx)(PCIDLIST_ABSOLUTE,WCHAR*,DWORD,GPFIDL_FLAGS);
 
@@ -134,8 +132,6 @@ static void init_function_pointers(void)
     MAKEFUNC(SHGetIDListFromObject);
     MAKEFUNC(SHGetItemFromObject);
     MAKEFUNC(SHCreateDefaultContextMenu);
-    MAKEFUNC(SHCreateShellFolderView);
-    MAKEFUNC(SHCreateShellFolderViewEx);
     MAKEFUNC(SHGetPathFromIDListEx);
 #undef MAKEFUNC
 
@@ -5147,123 +5143,6 @@ static void test_SHCreateDefaultContextMenu(void)
     Cleanup();
 }
 
-static void test_SHCreateShellFolderView(void)
-{
-    HRESULT hr;
-    IShellView *psv;
-    SFV_CREATE sfvc;
-    IShellFolder *desktop;
-    ULONG refCount;
-
-    if (!pSHCreateShellFolderView)
-    {
-        win_skip("SHCreateShellFolderView missing.\n");
-        return;
-    }
-
-    hr = SHGetDesktopFolder(&desktop);
-    ok(hr == S_OK, "got (0x%08x)\n", hr);
-
-    if (0)
-    {
-        /* crash on win7 */
-        pSHCreateShellFolderView(NULL, NULL);
-    }
-
-    psv = (void *)0xdeadbeef;
-    hr = pSHCreateShellFolderView(NULL, &psv);
-    ok(hr == E_INVALIDARG, "Got 0x%08x\n", hr);
-    ok(psv == NULL, "psv = %p\n", psv);
-
-    memset(&sfvc, 0, sizeof(sfvc));
-    psv = (void *)0xdeadbeef;
-    hr = pSHCreateShellFolderView(&sfvc, &psv);
-    ok(hr == E_INVALIDARG, "Got 0x%08x\n", hr);
-    ok(psv == NULL, "psv = %p\n", psv);
-
-    memset(&sfvc, 0, sizeof(sfvc));
-    sfvc.cbSize = sizeof(sfvc) - 1;
-    psv = (void *)0xdeadbeef;
-    hr = pSHCreateShellFolderView(&sfvc, &psv);
-    ok(hr == E_INVALIDARG, "Got 0x%08x\n", hr);
-    ok(psv == NULL, "psv = %p\n", psv);
-
-    memset(&sfvc, 0, sizeof(sfvc));
-    sfvc.cbSize = sizeof(sfvc) + 1;
-    psv = (void *)0xdeadbeef;
-    hr = pSHCreateShellFolderView(&sfvc, &psv);
-    ok(hr == E_INVALIDARG, "Got 0x%08x\n", hr);
-    ok(psv == NULL, "psv = %p\n", psv);
-
-    memset(&sfvc, 0, sizeof(sfvc));
-    sfvc.cbSize = sizeof(sfvc);
-    sfvc.pshf = desktop;
-    psv = NULL;
-    hr = pSHCreateShellFolderView(&sfvc, &psv);
-    ok(hr == S_OK, "Got 0x%08x\n", hr);
-    ok(psv != NULL, "psv = %p\n", psv);
-    if (psv)
-    {
-        refCount = IShellView_Release(psv);
-        ok(refCount == 0, "refCount = %u\n", refCount);
-    }
-
-    IShellFolder_Release(desktop);
-}
-
-static void test_SHCreateShellFolderViewEx(void)
-{
-    HRESULT hr;
-    IShellView *psv;
-    CSFV csfv;
-    IShellFolder *desktop;
-    ULONG refCount;
-
-    if (!pSHCreateShellFolderViewEx)
-    {
-        win_skip("SHCreateShellFolderViewEx missing.\n");
-        return;
-    }
-
-    hr = SHGetDesktopFolder(&desktop);
-    ok(hr == S_OK, "got (0x%08x)\n", hr);
-
-    if (0)
-    {
-        /* crash on win7 */
-        pSHCreateShellFolderViewEx(NULL, NULL);
-        pSHCreateShellFolderViewEx(NULL, &psv);
-        pSHCreateShellFolderViewEx(&csfv, NULL);
-    }
-
-    memset(&csfv, 0, sizeof(csfv));
-    csfv.pshf = desktop;
-    psv = NULL;
-    hr = pSHCreateShellFolderViewEx(&csfv, &psv);
-    ok(hr == S_OK, "Got 0x%08x\n", hr);
-    ok(psv != NULL, "psv = %p\n", psv);
-    if (psv)
-    {
-        refCount = IShellView_Release(psv);
-        ok(refCount == 0, "refCount = %u\n", refCount);
-    }
-
-    memset(&csfv, 0, sizeof(csfv));
-    csfv.cbSize = sizeof(csfv);
-    csfv.pshf = desktop;
-    psv = NULL;
-    hr = pSHCreateShellFolderViewEx(&csfv, &psv);
-    ok(hr == S_OK, "Got 0x%08x\n", hr);
-    ok(psv != NULL, "psv = %p\n", psv);
-    if (psv)
-    {
-        refCount = IShellView_Release(psv);
-        ok(refCount == 0, "refCount = %u\n", refCount);
-    }
-
-    IShellFolder_Release(desktop);
-}
-
 static void test_DataObject(void)
 {
     IShellFolder *desktop;
@@ -5359,8 +5238,6 @@ START_TEST(shlfolder)
     test_ShellItemGetAttributes();
     test_ShellItemArrayGetAttributes();
     test_SHCreateDefaultContextMenu();
-    test_SHCreateShellFolderView();
-    test_SHCreateShellFolderViewEx();
     test_DataObject();
 
     OleUninitialize();
diff --git a/dlls/shell32/tests/shlview.c b/dlls/shell32/tests/shlview.c
index 2c683e3523..c15d2d6fa4 100644
--- a/dlls/shell32/tests/shlview.c
+++ b/dlls/shell32/tests/shlview.c
@@ -1331,6 +1331,126 @@ static void test_IOleCommandTarget(void)
     IShellFolder_Release(psf_desktop);
 }
 
+static void test_SHCreateShellFolderView(void)
+{
+    IShellFolder *desktop;
+    IShellView *psv;
+    SFV_CREATE sfvc;
+    ULONG refCount;
+    HRESULT hr;
+
+    hr = SHGetDesktopFolder(&desktop);
+    ok(hr == S_OK, "got (0x%08x)\n", hr);
+
+    if (0)
+    {
+        /* crash on win7 */
+        SHCreateShellFolderView(NULL, NULL);
+    }
+
+    psv = (void *)0xdeadbeef;
+    hr = SHCreateShellFolderView(NULL, &psv);
+    ok(hr == E_INVALIDARG, "Got 0x%08x\n", hr);
+    ok(psv == NULL, "psv = %p\n", psv);
+
+    memset(&sfvc, 0, sizeof(sfvc));
+    psv = (void *)0xdeadbeef;
+    hr = SHCreateShellFolderView(&sfvc, &psv);
+    ok(hr == E_INVALIDARG, "Got 0x%08x\n", hr);
+    ok(psv == NULL, "psv = %p\n", psv);
+
+    memset(&sfvc, 0, sizeof(sfvc));
+    sfvc.cbSize = sizeof(sfvc) - 1;
+    psv = (void *)0xdeadbeef;
+    hr = SHCreateShellFolderView(&sfvc, &psv);
+    ok(hr == E_INVALIDARG, "Got 0x%08x\n", hr);
+    ok(psv == NULL, "psv = %p\n", psv);
+
+    memset(&sfvc, 0, sizeof(sfvc));
+    sfvc.cbSize = sizeof(sfvc) + 1;
+    psv = (void *)0xdeadbeef;
+    hr = SHCreateShellFolderView(&sfvc, &psv);
+    ok(hr == E_INVALIDARG, "Got 0x%08x\n", hr);
+    ok(psv == NULL, "psv = %p\n", psv);
+
+if (0)
+{
+    /* Crashes on NULL 'pshf' on XP/2k3 */
+    memset(&sfvc, 0, sizeof(sfvc));
+    sfvc.cbSize = sizeof(sfvc);
+    psv = (void *)0xdeadbeef;
+    hr = SHCreateShellFolderView(&sfvc, &psv);
+    ok(hr == E_UNEXPECTED, "Got 0x%08x\n", hr);
+    ok(psv == NULL, "psv = %p\n", psv);
+}
+    memset(&sfvc, 0, sizeof(sfvc));
+    sfvc.cbSize = sizeof(sfvc) - 1;
+    sfvc.pshf = desktop;
+    psv = (void *)0xdeadbeef;
+    hr = SHCreateShellFolderView(&sfvc, &psv);
+    ok(hr == E_INVALIDARG, "Got 0x%08x\n", hr);
+    ok(psv == NULL, "psv = %p\n", psv);
+
+    memset(&sfvc, 0, sizeof(sfvc));
+    sfvc.cbSize = sizeof(sfvc);
+    sfvc.pshf = desktop;
+    psv = NULL;
+    hr = SHCreateShellFolderView(&sfvc, &psv);
+    ok(hr == S_OK, "Got 0x%08x\n", hr);
+    ok(psv != NULL, "psv = %p\n", psv);
+    refCount = IShellView_Release(psv);
+    ok(refCount == 0, "refCount = %u\n", refCount);
+
+    IShellFolder_Release(desktop);
+}
+
+static void test_SHCreateShellFolderViewEx(void)
+{
+    IShellFolder *desktop;
+    IShellView *psv;
+    ULONG refCount;
+    HRESULT hr;
+    CSFV csfv;
+
+    hr = SHGetDesktopFolder(&desktop);
+    ok(hr == S_OK, "got (0x%08x)\n", hr);
+
+    if (0)
+    {
+        /* crash on win7 */
+        SHCreateShellFolderViewEx(NULL, NULL);
+        SHCreateShellFolderViewEx(NULL, &psv);
+        SHCreateShellFolderViewEx(&csfv, NULL);
+    }
+
+    memset(&csfv, 0, sizeof(csfv));
+    csfv.pshf = desktop;
+    psv = NULL;
+    hr = SHCreateShellFolderViewEx(&csfv, &psv);
+    ok(hr == S_OK, "Got 0x%08x\n", hr);
+    ok(psv != NULL, "psv = %p\n", psv);
+    if (psv)
+    {
+        refCount = IShellView_Release(psv);
+        ok(refCount == 0, "refCount = %u\n", refCount);
+    }
+
+    memset(&csfv, 0, sizeof(csfv));
+    csfv.cbSize = sizeof(csfv);
+    csfv.pshf = desktop;
+    psv = NULL;
+    hr = SHCreateShellFolderViewEx(&csfv, &psv);
+    ok(hr == S_OK, "Got 0x%08x\n", hr);
+    ok(psv != NULL, "psv = %p\n", psv);
+    if (psv)
+    {
+        refCount = IShellView_Release(psv);
+        ok(refCount == 0, "refCount = %u\n", refCount);
+    }
+
+    IShellFolder_Release(desktop);
+}
+
 START_TEST(shlview)
 {
     OleInitialize(NULL);
@@ -1344,6 +1464,8 @@ START_TEST(shlview)
     test_IOleWindow();
     test_GetSetCurrentViewMode();
     test_IOleCommandTarget();
+    test_SHCreateShellFolderView();
+    test_SHCreateShellFolderViewEx();
 
     OleUninitialize();
 }
-- 
2.11.0




More information about the wine-patches mailing list