Commit 4478e61d authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

shell32: Move SHCreateShellFolderView/SHCreateShellFolderViewEx and tests to corresponding files.

parent 90191451
......@@ -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;
}
......@@ -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;
}
......@@ -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();
......
......@@ -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();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment