2004-09-14 01:25:09 +02:00
|
|
|
/*
|
|
|
|
* Unit test of the IShellFolder functions.
|
|
|
|
*
|
|
|
|
* Copyright 2004 Vitaliy Margolen
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-09-14 01:25:09 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2004-10-07 04:59:11 +02:00
|
|
|
#define COBJMACROS
|
2006-09-29 12:45:44 +02:00
|
|
|
#define CONST_VTABLE
|
2004-10-07 04:59:11 +02:00
|
|
|
|
2004-09-14 01:25:09 +02:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "wtypes.h"
|
|
|
|
#include "shellapi.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include "shlguid.h"
|
|
|
|
#include "shlobj.h"
|
|
|
|
#include "shobjidl.h"
|
2005-06-14 19:21:25 +02:00
|
|
|
#include "shlwapi.h"
|
2005-08-23 11:37:59 +02:00
|
|
|
#include "ocidl.h"
|
|
|
|
#include "oleauto.h"
|
2004-09-14 01:25:09 +02:00
|
|
|
|
|
|
|
#include "wine/test.h"
|
|
|
|
|
2010-07-22 20:17:06 +02:00
|
|
|
#include <initguid.h>
|
|
|
|
DEFINE_GUID(IID_IParentAndItem, 0xB3A4B685, 0xB685, 0x4805, 0x99,0xD9, 0x5D,0xEA,0xD2,0x87,0x32,0x36);
|
2010-11-08 00:22:12 +01:00
|
|
|
DEFINE_GUID(CLSID_ShellDocObjView, 0xe7e4bc40, 0xe76a, 0x11ce, 0xa9,0xbb, 0x00,0xaa,0x00,0x4a,0xe8,0x37);
|
2004-09-14 01:25:09 +02:00
|
|
|
|
2005-06-07 22:30:30 +02:00
|
|
|
static IMalloc *ppM;
|
2004-09-14 01:25:09 +02:00
|
|
|
|
2005-06-20 12:31:14 +02:00
|
|
|
static HRESULT (WINAPI *pSHBindToParent)(LPCITEMIDLIST, REFIID, LPVOID*, LPCITEMIDLIST*);
|
2008-03-03 23:44:52 +01:00
|
|
|
static HRESULT (WINAPI *pSHGetFolderPathA)(HWND, int, HANDLE, DWORD, LPSTR);
|
|
|
|
static HRESULT (WINAPI *pSHGetFolderPathAndSubDirA)(HWND, int, HANDLE, DWORD, LPCSTR, LPSTR);
|
2007-12-18 10:01:05 +01:00
|
|
|
static BOOL (WINAPI *pSHGetPathFromIDListW)(LPCITEMIDLIST,LPWSTR);
|
2010-07-22 20:17:02 +02:00
|
|
|
static HRESULT (WINAPI *pSHGetSpecialFolderLocation)(HWND, int, LPITEMIDLIST *);
|
2009-01-21 16:44:10 +01:00
|
|
|
static BOOL (WINAPI *pSHGetSpecialFolderPathA)(HWND, LPSTR, int, BOOL);
|
2005-06-20 12:31:14 +02:00
|
|
|
static BOOL (WINAPI *pSHGetSpecialFolderPathW)(HWND, LPWSTR, int, BOOL);
|
2005-08-16 21:29:40 +02:00
|
|
|
static HRESULT (WINAPI *pStrRetToBufW)(STRRET*,LPCITEMIDLIST,LPWSTR,UINT);
|
2005-09-06 16:05:07 +02:00
|
|
|
static LPITEMIDLIST (WINAPI *pILFindLastID)(LPCITEMIDLIST);
|
2007-02-09 12:38:11 +01:00
|
|
|
static void (WINAPI *pILFree)(LPITEMIDLIST);
|
|
|
|
static BOOL (WINAPI *pILIsEqual)(LPCITEMIDLIST, LPCITEMIDLIST);
|
2010-07-22 20:17:04 +02:00
|
|
|
static HRESULT (WINAPI *pSHCreateItemFromIDList)(PCIDLIST_ABSOLUTE pidl, REFIID riid, void **ppv);
|
2010-07-22 20:17:03 +02:00
|
|
|
static HRESULT (WINAPI *pSHCreateItemFromParsingName)(PCWSTR,IBindCtx*,REFIID,void**);
|
2009-05-21 18:19:21 +02:00
|
|
|
static HRESULT (WINAPI *pSHCreateShellItem)(LPCITEMIDLIST,IShellFolder*,LPCITEMIDLIST,IShellItem**);
|
2010-07-26 11:54:03 +02:00
|
|
|
static HRESULT (WINAPI *pSHCreateShellItemArray)(LPCITEMIDLIST,IShellFolder*,UINT,LPCITEMIDLIST*,IShellItemArray**);
|
2010-07-26 11:54:05 +02:00
|
|
|
static HRESULT (WINAPI *pSHCreateShellItemArrayFromDataObject)(IDataObject*, REFIID, void **);
|
2010-07-26 11:54:04 +02:00
|
|
|
static HRESULT (WINAPI *pSHCreateShellItemArrayFromShellItem)(IShellItem*, REFIID, void **);
|
2009-05-21 18:19:21 +02:00
|
|
|
static LPITEMIDLIST (WINAPI *pILCombine)(LPCITEMIDLIST,LPCITEMIDLIST);
|
2010-03-03 02:56:20 +01:00
|
|
|
static HRESULT (WINAPI *pSHParseDisplayName)(LPCWSTR,IBindCtx*,LPITEMIDLIST*,SFGAOF,SFGAOF*);
|
2010-07-21 21:04:22 +02:00
|
|
|
static LPITEMIDLIST (WINAPI *pSHSimpleIDListFromPathAW)(LPCVOID);
|
2010-07-22 20:17:02 +02:00
|
|
|
static HRESULT (WINAPI *pSHGetNameFromIDList)(PCIDLIST_ABSOLUTE,SIGDN,PWSTR*);
|
2010-07-22 20:17:05 +02:00
|
|
|
static HRESULT (WINAPI *pSHGetItemFromDataObject)(IDataObject*,DATAOBJ_GET_ITEM_FLAGS,REFIID,void**);
|
2010-07-22 20:17:06 +02:00
|
|
|
static HRESULT (WINAPI *pSHGetIDListFromObject)(IUnknown*, PIDLIST_ABSOLUTE*);
|
2010-07-25 19:08:14 +02:00
|
|
|
static HRESULT (WINAPI *pSHGetItemFromObject)(IUnknown*,REFIID,void**);
|
2010-09-21 13:36:17 +02:00
|
|
|
static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL);
|
2011-07-29 01:29:39 +02:00
|
|
|
static UINT (WINAPI *pGetSystemWow64DirectoryW)(LPWSTR, UINT);
|
2011-08-01 23:47:52 +02:00
|
|
|
static HRESULT (WINAPI *pSHCreateDefaultContextMenu)(const DEFCONTEXTMENU*,REFIID,void**);
|
2005-06-20 12:31:14 +02:00
|
|
|
|
2010-11-12 22:32:49 +01:00
|
|
|
static WCHAR *make_wstr(const char *str)
|
|
|
|
{
|
|
|
|
WCHAR *ret;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
if(!str || strlen(str) == 0)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
|
|
|
|
if(!len || len < 0)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
ret = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
if(!ret)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-08-03 15:50:47 +02:00
|
|
|
static int strcmp_wa(LPCWSTR strw, const char *stra)
|
|
|
|
{
|
|
|
|
CHAR buf[512];
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), NULL, NULL);
|
|
|
|
return lstrcmpA(stra, buf);
|
|
|
|
}
|
|
|
|
|
2005-06-20 12:31:14 +02:00
|
|
|
static void init_function_pointers(void)
|
|
|
|
{
|
2005-08-16 21:29:40 +02:00
|
|
|
HMODULE hmod;
|
2005-06-29 13:00:59 +02:00
|
|
|
HRESULT hr;
|
2010-05-26 01:01:15 +02:00
|
|
|
void *ptr;
|
2005-06-20 12:31:14 +02:00
|
|
|
|
2005-08-16 21:29:40 +02:00
|
|
|
hmod = GetModuleHandleA("shell32.dll");
|
2010-03-02 22:00:52 +01:00
|
|
|
|
|
|
|
#define MAKEFUNC(f) (p##f = (void*)GetProcAddress(hmod, #f))
|
|
|
|
MAKEFUNC(SHBindToParent);
|
2010-07-22 20:17:04 +02:00
|
|
|
MAKEFUNC(SHCreateItemFromIDList);
|
2010-07-22 20:17:03 +02:00
|
|
|
MAKEFUNC(SHCreateItemFromParsingName);
|
2010-03-02 22:00:52 +01:00
|
|
|
MAKEFUNC(SHCreateShellItem);
|
2010-07-26 11:54:03 +02:00
|
|
|
MAKEFUNC(SHCreateShellItemArray);
|
2010-07-26 11:54:05 +02:00
|
|
|
MAKEFUNC(SHCreateShellItemArrayFromDataObject);
|
2010-07-26 11:54:04 +02:00
|
|
|
MAKEFUNC(SHCreateShellItemArrayFromShellItem);
|
2010-03-02 22:00:52 +01:00
|
|
|
MAKEFUNC(SHGetFolderPathA);
|
|
|
|
MAKEFUNC(SHGetFolderPathAndSubDirA);
|
|
|
|
MAKEFUNC(SHGetPathFromIDListW);
|
|
|
|
MAKEFUNC(SHGetSpecialFolderPathA);
|
|
|
|
MAKEFUNC(SHGetSpecialFolderPathW);
|
2010-07-22 20:17:02 +02:00
|
|
|
MAKEFUNC(SHGetSpecialFolderLocation);
|
2010-03-03 02:56:20 +01:00
|
|
|
MAKEFUNC(SHParseDisplayName);
|
2010-07-22 20:17:02 +02:00
|
|
|
MAKEFUNC(SHGetNameFromIDList);
|
2010-07-22 20:17:05 +02:00
|
|
|
MAKEFUNC(SHGetItemFromDataObject);
|
2010-07-22 20:17:06 +02:00
|
|
|
MAKEFUNC(SHGetIDListFromObject);
|
2010-07-25 19:08:14 +02:00
|
|
|
MAKEFUNC(SHGetItemFromObject);
|
2011-08-01 23:47:52 +02:00
|
|
|
MAKEFUNC(SHCreateDefaultContextMenu);
|
2010-03-02 22:00:52 +01:00
|
|
|
#undef MAKEFUNC
|
|
|
|
|
|
|
|
#define MAKEFUNC_ORD(f, ord) (p##f = (void*)GetProcAddress(hmod, (LPSTR)(ord)))
|
|
|
|
MAKEFUNC_ORD(ILFindLastID, 16);
|
|
|
|
MAKEFUNC_ORD(ILIsEqual, 21);
|
|
|
|
MAKEFUNC_ORD(ILCombine, 25);
|
|
|
|
MAKEFUNC_ORD(ILFree, 155);
|
2010-07-21 21:04:22 +02:00
|
|
|
MAKEFUNC_ORD(SHSimpleIDListFromPathAW, 162);
|
2010-03-02 22:00:52 +01:00
|
|
|
#undef MAKEFUNC_ORD
|
2005-06-29 13:00:59 +02:00
|
|
|
|
2010-05-26 01:01:15 +02:00
|
|
|
/* test named exports */
|
|
|
|
ptr = GetProcAddress(hmod, "ILFree");
|
|
|
|
ok(broken(ptr == 0) || ptr != 0, "expected named export for ILFree\n");
|
|
|
|
if (ptr)
|
|
|
|
{
|
|
|
|
#define TESTNAMED(f) \
|
|
|
|
ptr = (void*)GetProcAddress(hmod, #f); \
|
|
|
|
ok(ptr != 0, "expected named export for " #f "\n");
|
|
|
|
|
|
|
|
TESTNAMED(ILAppendID);
|
|
|
|
TESTNAMED(ILClone);
|
|
|
|
TESTNAMED(ILCloneFirst);
|
|
|
|
TESTNAMED(ILCombine);
|
|
|
|
TESTNAMED(ILCreateFromPath);
|
|
|
|
TESTNAMED(ILCreateFromPathA);
|
|
|
|
TESTNAMED(ILCreateFromPathW);
|
|
|
|
TESTNAMED(ILFindChild);
|
|
|
|
TESTNAMED(ILFindLastID);
|
|
|
|
TESTNAMED(ILGetNext);
|
|
|
|
TESTNAMED(ILGetSize);
|
|
|
|
TESTNAMED(ILIsEqual);
|
|
|
|
TESTNAMED(ILIsParent);
|
|
|
|
TESTNAMED(ILRemoveLastID);
|
|
|
|
TESTNAMED(ILSaveToStream);
|
|
|
|
#undef TESTNAMED
|
|
|
|
}
|
|
|
|
|
2005-08-16 21:29:40 +02:00
|
|
|
hmod = GetModuleHandleA("shlwapi.dll");
|
2007-03-28 10:00:28 +02:00
|
|
|
pStrRetToBufW = (void*)GetProcAddress(hmod, "StrRetToBufW");
|
2005-08-16 21:29:40 +02:00
|
|
|
|
2011-07-29 01:29:39 +02:00
|
|
|
hmod = GetModuleHandleA("kernel32.dll");
|
|
|
|
pIsWow64Process = (void*)GetProcAddress(hmod, "IsWow64Process");
|
|
|
|
pGetSystemWow64DirectoryW = (void*)GetProcAddress(hmod, "GetSystemWow64DirectoryW");
|
2010-09-21 13:36:17 +02:00
|
|
|
|
2005-06-29 13:00:59 +02:00
|
|
|
hr = SHGetMalloc(&ppM);
|
2006-10-07 20:18:17 +02:00
|
|
|
ok(hr == S_OK, "SHGetMalloc failed %08x\n", hr);
|
2005-06-20 12:31:14 +02:00
|
|
|
}
|
|
|
|
|
2010-11-08 00:22:12 +01:00
|
|
|
/* Based on PathAddBackslashW from dlls/shlwapi/path.c */
|
|
|
|
static LPWSTR myPathAddBackslashW( LPWSTR lpszPath )
|
|
|
|
{
|
|
|
|
size_t iLen;
|
|
|
|
|
|
|
|
if (!lpszPath || (iLen = lstrlenW(lpszPath)) >= MAX_PATH)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (iLen)
|
|
|
|
{
|
|
|
|
lpszPath += iLen;
|
|
|
|
if (lpszPath[-1] != '\\')
|
|
|
|
{
|
|
|
|
*lpszPath++ = '\\';
|
|
|
|
*lpszPath = '\0';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return lpszPath;
|
|
|
|
}
|
|
|
|
|
2005-08-02 16:41:51 +02:00
|
|
|
static void test_ParseDisplayName(void)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IShellFolder *IDesktopFolder;
|
|
|
|
static const char *cNonExistDir1A = "c:\\nonexist_subdir";
|
|
|
|
static const char *cNonExistDir2A = "c:\\\\nonexist_subdir";
|
2009-01-28 17:32:38 +01:00
|
|
|
static const char *cInetTestA = "http:\\yyy";
|
|
|
|
static const char *cInetTest2A = "xx:yyy";
|
2005-08-02 16:41:51 +02:00
|
|
|
DWORD res;
|
|
|
|
WCHAR cTestDirW [MAX_PATH] = {0};
|
|
|
|
ITEMIDLIST *newPIDL;
|
2006-02-24 22:24:12 +01:00
|
|
|
BOOL bRes;
|
2005-08-02 16:41:51 +02:00
|
|
|
|
|
|
|
hr = SHGetDesktopFolder(&IDesktopFolder);
|
2010-04-18 22:10:43 +02:00
|
|
|
ok(hr == S_OK, "Expected SHGetDesktopFolder to return S_OK, got 0x%08x\n", hr);
|
2005-08-02 16:41:51 +02:00
|
|
|
if(hr != S_OK) return;
|
|
|
|
|
2010-03-04 08:49:34 +01:00
|
|
|
/* Tests crash on W2K and below (SHCreateShellItem available as of XP) */
|
|
|
|
if (pSHCreateShellItem)
|
|
|
|
{
|
|
|
|
/* null name and pidl */
|
|
|
|
hr = IShellFolder_ParseDisplayName(IDesktopFolder,
|
|
|
|
NULL, NULL, NULL, NULL, NULL, 0);
|
|
|
|
ok(hr == E_INVALIDARG, "returned %08x, expected E_INVALIDARG\n", hr);
|
|
|
|
|
|
|
|
/* null name */
|
|
|
|
newPIDL = (ITEMIDLIST*)0xdeadbeef;
|
|
|
|
hr = IShellFolder_ParseDisplayName(IDesktopFolder,
|
|
|
|
NULL, NULL, NULL, NULL, &newPIDL, 0);
|
|
|
|
ok(newPIDL == 0, "expected null, got %p\n", newPIDL);
|
|
|
|
ok(hr == E_INVALIDARG, "returned %08x, expected E_INVALIDARG\n", hr);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
win_skip("Tests would crash on W2K and below\n");
|
2010-03-03 02:56:20 +01:00
|
|
|
|
2009-01-28 17:32:38 +01:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, cInetTestA, -1, cTestDirW, MAX_PATH);
|
|
|
|
hr = IShellFolder_ParseDisplayName(IDesktopFolder,
|
|
|
|
NULL, NULL, cTestDirW, NULL, &newPIDL, 0);
|
2010-03-23 02:21:13 +01:00
|
|
|
todo_wine ok(hr == S_OK || broken(hr == E_FAIL) /* NT4 */,
|
2009-02-05 00:10:35 +01:00
|
|
|
"ParseDisplayName returned %08x, expected SUCCESS or E_FAIL\n", hr);
|
2010-03-23 02:21:13 +01:00
|
|
|
if (hr == S_OK)
|
2009-01-28 17:32:38 +01:00
|
|
|
{
|
|
|
|
ok(pILFindLastID(newPIDL)->mkid.abID[0] == 0x61, "Last pidl should be of type "
|
|
|
|
"PT_IESPECIAL1, but is: %02x\n", pILFindLastID(newPIDL)->mkid.abID[0]);
|
|
|
|
IMalloc_Free(ppM, newPIDL);
|
|
|
|
}
|
|
|
|
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, cInetTest2A, -1, cTestDirW, MAX_PATH);
|
|
|
|
hr = IShellFolder_ParseDisplayName(IDesktopFolder,
|
|
|
|
NULL, NULL, cTestDirW, NULL, &newPIDL, 0);
|
2010-03-23 02:21:13 +01:00
|
|
|
todo_wine ok(hr == S_OK || broken(hr == E_FAIL) /* NT4 */,
|
2009-02-05 00:10:35 +01:00
|
|
|
"ParseDisplayName returned %08x, expected SUCCESS or E_FAIL\n", hr);
|
2010-03-23 02:21:13 +01:00
|
|
|
if (hr == S_OK)
|
2009-01-28 17:32:38 +01:00
|
|
|
{
|
|
|
|
ok(pILFindLastID(newPIDL)->mkid.abID[0] == 0x61, "Last pidl should be of type "
|
|
|
|
"PT_IESPECIAL1, but is: %02x\n", pILFindLastID(newPIDL)->mkid.abID[0]);
|
|
|
|
IMalloc_Free(ppM, newPIDL);
|
|
|
|
}
|
|
|
|
|
2005-08-02 16:41:51 +02:00
|
|
|
res = GetFileAttributesA(cNonExistDir1A);
|
2010-04-18 22:10:43 +02:00
|
|
|
if(res != INVALID_FILE_ATTRIBUTES)
|
|
|
|
{
|
|
|
|
skip("Test directory unexpectedly exists\n");
|
|
|
|
goto finished;
|
|
|
|
}
|
2005-08-02 16:41:51 +02:00
|
|
|
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, cNonExistDir1A, -1, cTestDirW, MAX_PATH);
|
|
|
|
hr = IShellFolder_ParseDisplayName(IDesktopFolder,
|
|
|
|
NULL, NULL, cTestDirW, NULL, &newPIDL, 0);
|
2005-08-08 13:04:30 +02:00
|
|
|
ok((hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)) || (hr == E_FAIL),
|
2006-10-07 20:18:17 +02:00
|
|
|
"ParseDisplayName returned %08x, expected 80070002 or E_FAIL\n", hr);
|
2005-08-02 16:41:51 +02:00
|
|
|
|
|
|
|
res = GetFileAttributesA(cNonExistDir2A);
|
2010-04-18 22:10:43 +02:00
|
|
|
if(res != INVALID_FILE_ATTRIBUTES)
|
|
|
|
{
|
|
|
|
skip("Test directory unexpectedly exists\n");
|
|
|
|
goto finished;
|
|
|
|
}
|
2005-08-02 16:41:51 +02:00
|
|
|
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, cNonExistDir2A, -1, cTestDirW, MAX_PATH);
|
|
|
|
hr = IShellFolder_ParseDisplayName(IDesktopFolder,
|
|
|
|
NULL, NULL, cTestDirW, NULL, &newPIDL, 0);
|
2005-08-15 11:40:45 +02:00
|
|
|
ok((hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)) || (hr == E_FAIL) || (hr == E_INVALIDARG),
|
2006-10-07 20:18:17 +02:00
|
|
|
"ParseDisplayName returned %08x, expected 80070002, E_FAIL or E_INVALIDARG\n", hr);
|
2006-02-11 12:16:56 +01:00
|
|
|
|
2006-02-24 22:24:12 +01:00
|
|
|
/* I thought that perhaps the DesktopFolder's ParseDisplayName would recognize the
|
|
|
|
* path corresponding to CSIDL_PERSONAL and return a CLSID_MyDocuments PIDL. Turns
|
|
|
|
* out it doesn't. The magic seems to happen in the file dialogs, then. */
|
2010-04-18 22:10:43 +02:00
|
|
|
if (!pSHGetSpecialFolderPathW || !pILFindLastID)
|
|
|
|
{
|
|
|
|
win_skip("SHGetSpecialFolderPathW and/or ILFindLastID are not available\n");
|
|
|
|
goto finished;
|
|
|
|
}
|
|
|
|
|
2006-02-24 22:24:12 +01:00
|
|
|
bRes = pSHGetSpecialFolderPathW(NULL, cTestDirW, CSIDL_PERSONAL, FALSE);
|
2007-01-05 21:48:19 +01:00
|
|
|
ok(bRes, "SHGetSpecialFolderPath(CSIDL_PERSONAL) failed! %u\n", GetLastError());
|
2006-02-24 22:24:12 +01:00
|
|
|
if (!bRes) goto finished;
|
|
|
|
|
|
|
|
hr = IShellFolder_ParseDisplayName(IDesktopFolder, NULL, NULL, cTestDirW, NULL, &newPIDL, 0);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(hr == S_OK, "DesktopFolder->ParseDisplayName failed. hr = %08x.\n", hr);
|
|
|
|
if (hr != S_OK) goto finished;
|
2006-02-24 22:24:12 +01:00
|
|
|
|
2009-04-24 09:29:12 +02:00
|
|
|
ok(pILFindLastID(newPIDL)->mkid.abID[0] == 0x31 ||
|
|
|
|
pILFindLastID(newPIDL)->mkid.abID[0] == 0xb1, /* Win98 */
|
|
|
|
"Last pidl should be of type PT_FOLDER or PT_IESPECIAL2, but is: %02x\n",
|
|
|
|
pILFindLastID(newPIDL)->mkid.abID[0]);
|
2006-02-24 22:24:12 +01:00
|
|
|
IMalloc_Free(ppM, newPIDL);
|
|
|
|
|
|
|
|
finished:
|
|
|
|
IShellFolder_Release(IDesktopFolder);
|
2005-08-02 16:41:51 +02:00
|
|
|
}
|
|
|
|
|
2004-09-14 01:25:09 +02:00
|
|
|
/* creates a file with the specified name for tests */
|
2005-06-07 22:30:30 +02:00
|
|
|
static void CreateTestFile(const CHAR *name)
|
2004-09-14 01:25:09 +02:00
|
|
|
{
|
|
|
|
HANDLE file;
|
|
|
|
DWORD written;
|
|
|
|
|
|
|
|
file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
|
|
|
|
if (file != INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
WriteFile(file, name, strlen(name), &written, NULL);
|
|
|
|
WriteFile(file, "\n", strlen("\n"), &written, NULL);
|
|
|
|
CloseHandle(file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* initializes the tests */
|
2005-06-07 22:30:30 +02:00
|
|
|
static void CreateFilesFolders(void)
|
2004-09-14 01:25:09 +02:00
|
|
|
{
|
|
|
|
CreateDirectoryA(".\\testdir", NULL);
|
|
|
|
CreateDirectoryA(".\\testdir\\test.txt", NULL);
|
|
|
|
CreateTestFile (".\\testdir\\test1.txt ");
|
|
|
|
CreateTestFile (".\\testdir\\test2.txt ");
|
|
|
|
CreateTestFile (".\\testdir\\test3.txt ");
|
|
|
|
CreateDirectoryA(".\\testdir\\testdir2 ", NULL);
|
2005-04-11 20:50:01 +02:00
|
|
|
CreateDirectoryA(".\\testdir\\testdir2\\subdir", NULL);
|
2004-09-14 01:25:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* cleans after tests */
|
2005-06-07 22:30:30 +02:00
|
|
|
static void Cleanup(void)
|
2004-09-14 01:25:09 +02:00
|
|
|
{
|
|
|
|
DeleteFileA(".\\testdir\\test1.txt");
|
|
|
|
DeleteFileA(".\\testdir\\test2.txt");
|
|
|
|
DeleteFileA(".\\testdir\\test3.txt");
|
|
|
|
RemoveDirectoryA(".\\testdir\\test.txt");
|
2005-04-11 20:50:01 +02:00
|
|
|
RemoveDirectoryA(".\\testdir\\testdir2\\subdir");
|
2004-09-14 01:25:09 +02:00
|
|
|
RemoveDirectoryA(".\\testdir\\testdir2");
|
|
|
|
RemoveDirectoryA(".\\testdir");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* perform test */
|
2005-06-07 22:30:30 +02:00
|
|
|
static void test_EnumObjects(IShellFolder *iFolder)
|
2004-09-14 01:25:09 +02:00
|
|
|
{
|
|
|
|
IEnumIDList *iEnumList;
|
2005-07-08 13:30:18 +02:00
|
|
|
LPITEMIDLIST newPIDL, idlArr[10];
|
2004-09-14 01:25:09 +02:00
|
|
|
ULONG NumPIDLs;
|
|
|
|
int i=0, j;
|
2005-04-11 20:50:01 +02:00
|
|
|
HRESULT hr;
|
2004-09-14 01:25:09 +02:00
|
|
|
|
|
|
|
static const WORD iResults [5][5] =
|
|
|
|
{
|
|
|
|
{ 0,-1,-1,-1,-1},
|
2004-10-11 21:52:23 +02:00
|
|
|
{ 1, 0,-1,-1,-1},
|
|
|
|
{ 1, 1, 0,-1,-1},
|
|
|
|
{ 1, 1, 1, 0,-1},
|
|
|
|
{ 1, 1, 1, 1, 0}
|
2004-09-14 01:25:09 +02:00
|
|
|
};
|
|
|
|
|
2005-11-03 10:56:07 +01:00
|
|
|
#define SFGAO_testfor SFGAO_FILESYSTEM | SFGAO_FOLDER | SFGAO_FILESYSANCESTOR | SFGAO_CAPABILITYMASK
|
|
|
|
/* Don't test for SFGAO_HASSUBFOLDER since we return real state and native cached */
|
2005-04-11 20:50:01 +02:00
|
|
|
static const ULONG attrs[5] =
|
2004-09-14 01:25:09 +02:00
|
|
|
{
|
2005-11-03 10:56:07 +01:00
|
|
|
SFGAO_CAPABILITYMASK | SFGAO_FILESYSTEM | SFGAO_FOLDER | SFGAO_FILESYSANCESTOR,
|
|
|
|
SFGAO_CAPABILITYMASK | SFGAO_FILESYSTEM | SFGAO_FOLDER | SFGAO_FILESYSANCESTOR,
|
|
|
|
SFGAO_CAPABILITYMASK | SFGAO_FILESYSTEM,
|
|
|
|
SFGAO_CAPABILITYMASK | SFGAO_FILESYSTEM,
|
|
|
|
SFGAO_CAPABILITYMASK | SFGAO_FILESYSTEM,
|
2005-04-11 20:50:01 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
hr = IShellFolder_EnumObjects(iFolder, NULL, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS | SHCONTF_INCLUDEHIDDEN, &iEnumList);
|
2006-10-07 20:18:17 +02:00
|
|
|
ok(hr == S_OK, "EnumObjects failed %08x\n", hr);
|
2005-04-11 20:50:01 +02:00
|
|
|
|
2005-07-11 12:59:41 +02:00
|
|
|
/* This is to show that, contrary to what is said on MSDN, on IEnumIDList::Next,
|
|
|
|
* the filesystem shellfolders return S_OK even if less than 'celt' items are
|
2005-07-08 13:30:18 +02:00
|
|
|
* returned (in contrast to S_FALSE). We have to do it in a loop since WinXP
|
|
|
|
* only ever returns a single entry per call. */
|
|
|
|
while (IEnumIDList_Next(iEnumList, 10-i, &idlArr[i], &NumPIDLs) == S_OK)
|
|
|
|
i += NumPIDLs;
|
|
|
|
ok (i == 5, "i: %d\n", i);
|
2005-04-11 20:50:01 +02:00
|
|
|
|
|
|
|
hr = IEnumIDList_Release(iEnumList);
|
2006-10-07 20:18:17 +02:00
|
|
|
ok(hr == S_OK, "IEnumIDList_Release failed %08x\n", hr);
|
2004-09-14 01:25:09 +02:00
|
|
|
|
2005-04-11 20:50:01 +02:00
|
|
|
/* Sort them first in case of wrong order from system */
|
|
|
|
for (i=0;i<5;i++) for (j=0;j<5;j++)
|
|
|
|
if ((SHORT)IShellFolder_CompareIDs(iFolder, 0, idlArr[i], idlArr[j]) < 0)
|
2004-09-14 01:25:09 +02:00
|
|
|
{
|
2005-04-11 20:50:01 +02:00
|
|
|
newPIDL = idlArr[i];
|
|
|
|
idlArr[i] = idlArr[j];
|
|
|
|
idlArr[j] = newPIDL;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i=0;i<5;i++) for (j=0;j<5;j++)
|
|
|
|
{
|
|
|
|
hr = IShellFolder_CompareIDs(iFolder, 0, idlArr[i], idlArr[j]);
|
2006-10-07 20:18:17 +02:00
|
|
|
ok(hr == iResults[i][j], "Got %x expected [%d]-[%d]=%x\n", hr, i, j, iResults[i][j]);
|
2005-04-11 20:50:01 +02:00
|
|
|
}
|
|
|
|
|
2004-09-14 01:25:09 +02:00
|
|
|
|
2005-04-11 20:50:01 +02:00
|
|
|
for (i = 0; i < 5; i++)
|
|
|
|
{
|
|
|
|
SFGAOF flags;
|
2009-06-18 18:20:18 +02:00
|
|
|
#define SFGAO_VISTA SFGAO_DROPTARGET | SFGAO_CANLINK | SFGAO_CANCOPY
|
2005-11-03 10:56:07 +01:00
|
|
|
/* Native returns all flags no matter what we ask for */
|
|
|
|
flags = SFGAO_CANCOPY;
|
2005-04-11 20:50:01 +02:00
|
|
|
hr = IShellFolder_GetAttributesOf(iFolder, 1, (LPCITEMIDLIST*)(idlArr + i), &flags);
|
2005-11-03 10:56:07 +01:00
|
|
|
flags &= SFGAO_testfor;
|
2006-10-07 20:18:17 +02:00
|
|
|
ok(hr == S_OK, "GetAttributesOf returns %08x\n", hr);
|
2009-04-24 09:07:23 +02:00
|
|
|
ok(flags == (attrs[i]) ||
|
2009-06-18 18:20:18 +02:00
|
|
|
flags == (attrs[i] & ~SFGAO_FILESYSANCESTOR) || /* Win9x, NT4 */
|
|
|
|
flags == ((attrs[i] & ~SFGAO_CAPABILITYMASK) | SFGAO_VISTA), /* Vista and higher */
|
2009-04-24 09:07:23 +02:00
|
|
|
"GetAttributesOf[%i] got %08x, expected %08x\n", i, flags, attrs[i]);
|
2005-11-03 10:56:07 +01:00
|
|
|
|
|
|
|
flags = SFGAO_testfor;
|
|
|
|
hr = IShellFolder_GetAttributesOf(iFolder, 1, (LPCITEMIDLIST*)(idlArr + i), &flags);
|
|
|
|
flags &= SFGAO_testfor;
|
2006-10-07 20:18:17 +02:00
|
|
|
ok(hr == S_OK, "GetAttributesOf returns %08x\n", hr);
|
2009-04-24 09:07:23 +02:00
|
|
|
ok(flags == attrs[i] ||
|
|
|
|
flags == (attrs[i] & ~SFGAO_FILESYSANCESTOR), /* Win9x, NT4 */
|
|
|
|
"GetAttributesOf[%i] got %08x, expected %08x\n", i, flags, attrs[i]);
|
2004-09-14 01:25:09 +02:00
|
|
|
}
|
2005-04-11 20:50:01 +02:00
|
|
|
|
|
|
|
for (i=0;i<5;i++)
|
|
|
|
IMalloc_Free(ppM, idlArr[i]);
|
2004-09-14 01:25:09 +02:00
|
|
|
}
|
|
|
|
|
2005-06-07 22:30:30 +02:00
|
|
|
static void test_BindToObject(void)
|
2005-06-06 12:04:15 +02:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
UINT cChars;
|
|
|
|
IShellFolder *psfDesktop, *psfChild, *psfMyComputer, *psfSystemDir;
|
|
|
|
SHITEMID emptyitem = { 0, { 0 } };
|
2010-11-08 00:22:12 +01:00
|
|
|
LPITEMIDLIST pidlMyComputer, pidlSystemDir, pidl, pidlEmpty = (LPITEMIDLIST)&emptyitem;
|
2005-06-06 12:04:15 +02:00
|
|
|
WCHAR wszSystemDir[MAX_PATH];
|
2005-08-22 11:14:35 +02:00
|
|
|
char szSystemDir[MAX_PATH];
|
2010-11-08 00:22:12 +01:00
|
|
|
char buf[MAX_PATH];
|
|
|
|
WCHAR path[MAX_PATH];
|
2010-11-28 21:03:09 +01:00
|
|
|
CHAR pathA[MAX_PATH];
|
2010-11-08 00:22:12 +01:00
|
|
|
HANDLE hfile;
|
2005-06-06 12:04:15 +02:00
|
|
|
WCHAR wszMyComputer[] = {
|
|
|
|
':',':','{','2','0','D','0','4','F','E','0','-','3','A','E','A','-','1','0','6','9','-',
|
|
|
|
'A','2','D','8','-','0','8','0','0','2','B','3','0','3','0','9','D','}',0 };
|
2010-11-28 21:03:09 +01:00
|
|
|
static const CHAR filename_html[] = "winetest.html";
|
|
|
|
static const CHAR filename_txt[] = "winetest.txt";
|
|
|
|
static const CHAR filename_foo[] = "winetest.foo";
|
2005-06-06 12:04:15 +02:00
|
|
|
|
|
|
|
/* The following tests shows that BindToObject should fail with E_INVALIDARG if called
|
|
|
|
* with an empty pidl. This is tested for Desktop, MyComputer and the FS ShellFolder
|
|
|
|
*/
|
|
|
|
hr = SHGetDesktopFolder(&psfDesktop);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok (hr == S_OK, "SHGetDesktopFolder failed! hr = %08x\n", hr);
|
|
|
|
if (hr != S_OK) return;
|
2005-06-06 12:04:15 +02:00
|
|
|
|
|
|
|
hr = IShellFolder_BindToObject(psfDesktop, pidlEmpty, NULL, &IID_IShellFolder, (LPVOID*)&psfChild);
|
2006-10-07 20:18:17 +02:00
|
|
|
ok (hr == E_INVALIDARG, "Desktop's BindToObject should fail, when called with empty pidl! hr = %08x\n", hr);
|
2005-06-06 12:04:15 +02:00
|
|
|
|
2005-06-27 11:41:48 +02:00
|
|
|
hr = IShellFolder_BindToObject(psfDesktop, NULL, NULL, &IID_IShellFolder, (LPVOID*)&psfChild);
|
2006-10-07 20:18:17 +02:00
|
|
|
ok (hr == E_INVALIDARG, "Desktop's BindToObject should fail, when called with NULL pidl! hr = %08x\n", hr);
|
2005-06-27 11:41:48 +02:00
|
|
|
|
2005-06-06 12:04:15 +02:00
|
|
|
hr = IShellFolder_ParseDisplayName(psfDesktop, NULL, NULL, wszMyComputer, NULL, &pidlMyComputer, NULL);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok (hr == S_OK, "Desktop's ParseDisplayName failed to parse MyComputer's CLSID! hr = %08x\n", hr);
|
|
|
|
if (hr != S_OK) {
|
2005-06-06 12:04:15 +02:00
|
|
|
IShellFolder_Release(psfDesktop);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IShellFolder_BindToObject(psfDesktop, pidlMyComputer, NULL, &IID_IShellFolder, (LPVOID*)&psfMyComputer);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok (hr == S_OK, "Desktop failed to bind to MyComputer object! hr = %08x\n", hr);
|
2005-06-06 12:04:15 +02:00
|
|
|
IShellFolder_Release(psfDesktop);
|
2005-06-29 13:00:59 +02:00
|
|
|
IMalloc_Free(ppM, pidlMyComputer);
|
2010-03-23 02:21:13 +01:00
|
|
|
if (hr != S_OK) return;
|
2005-06-06 12:04:15 +02:00
|
|
|
|
|
|
|
hr = IShellFolder_BindToObject(psfMyComputer, pidlEmpty, NULL, &IID_IShellFolder, (LPVOID*)&psfChild);
|
2006-10-07 20:18:17 +02:00
|
|
|
ok (hr == E_INVALIDARG, "MyComputers's BindToObject should fail, when called with empty pidl! hr = %08x\n", hr);
|
2005-06-06 12:04:15 +02:00
|
|
|
|
2010-03-02 22:00:52 +01:00
|
|
|
if (0)
|
|
|
|
{
|
2005-11-09 11:30:15 +01:00
|
|
|
/* this call segfaults on 98SE */
|
2005-06-27 11:41:48 +02:00
|
|
|
hr = IShellFolder_BindToObject(psfMyComputer, NULL, NULL, &IID_IShellFolder, (LPVOID*)&psfChild);
|
2006-10-07 20:18:17 +02:00
|
|
|
ok (hr == E_INVALIDARG, "MyComputers's BindToObject should fail, when called with NULL pidl! hr = %08x\n", hr);
|
2010-03-02 22:00:52 +01:00
|
|
|
}
|
2005-06-27 11:41:48 +02:00
|
|
|
|
2005-08-22 11:14:35 +02:00
|
|
|
cChars = GetSystemDirectoryA(szSystemDir, MAX_PATH);
|
2007-01-05 21:48:19 +01:00
|
|
|
ok (cChars > 0 && cChars < MAX_PATH, "GetSystemDirectoryA failed! LastError: %u\n", GetLastError());
|
2005-06-06 12:04:15 +02:00
|
|
|
if (cChars == 0 || cChars >= MAX_PATH) {
|
|
|
|
IShellFolder_Release(psfMyComputer);
|
|
|
|
return;
|
|
|
|
}
|
2005-08-22 11:14:35 +02:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, szSystemDir, -1, wszSystemDir, MAX_PATH);
|
2005-06-06 12:04:15 +02:00
|
|
|
|
|
|
|
hr = IShellFolder_ParseDisplayName(psfMyComputer, NULL, NULL, wszSystemDir, NULL, &pidlSystemDir, NULL);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok (hr == S_OK, "MyComputers's ParseDisplayName failed to parse the SystemDirectory! hr = %08x\n", hr);
|
|
|
|
if (hr != S_OK) {
|
2005-06-06 12:04:15 +02:00
|
|
|
IShellFolder_Release(psfMyComputer);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IShellFolder_BindToObject(psfMyComputer, pidlSystemDir, NULL, &IID_IShellFolder, (LPVOID*)&psfSystemDir);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok (hr == S_OK, "MyComputer failed to bind to a FileSystem ShellFolder! hr = %08x\n", hr);
|
2005-06-06 12:04:15 +02:00
|
|
|
IShellFolder_Release(psfMyComputer);
|
2005-06-29 13:00:59 +02:00
|
|
|
IMalloc_Free(ppM, pidlSystemDir);
|
2010-03-23 02:21:13 +01:00
|
|
|
if (hr != S_OK) return;
|
2005-06-06 12:04:15 +02:00
|
|
|
|
|
|
|
hr = IShellFolder_BindToObject(psfSystemDir, pidlEmpty, NULL, &IID_IShellFolder, (LPVOID*)&psfChild);
|
|
|
|
ok (hr == E_INVALIDARG,
|
2006-10-07 20:18:17 +02:00
|
|
|
"FileSystem ShellFolder's BindToObject should fail, when called with empty pidl! hr = %08x\n", hr);
|
2010-03-02 22:00:52 +01:00
|
|
|
|
|
|
|
if (0)
|
|
|
|
{
|
2005-11-09 11:30:15 +01:00
|
|
|
/* this call segfaults on 98SE */
|
2005-06-27 11:41:48 +02:00
|
|
|
hr = IShellFolder_BindToObject(psfSystemDir, NULL, NULL, &IID_IShellFolder, (LPVOID*)&psfChild);
|
2010-03-02 22:00:52 +01:00
|
|
|
ok (hr == E_INVALIDARG,
|
2006-10-07 20:18:17 +02:00
|
|
|
"FileSystem ShellFolder's BindToObject should fail, when called with NULL pidl! hr = %08x\n", hr);
|
2010-03-02 22:00:52 +01:00
|
|
|
}
|
2005-06-27 11:41:48 +02:00
|
|
|
|
2005-06-06 12:04:15 +02:00
|
|
|
IShellFolder_Release(psfSystemDir);
|
2007-12-18 10:00:47 +01:00
|
|
|
|
2010-11-08 00:22:12 +01:00
|
|
|
GetCurrentDirectoryA(MAX_PATH, buf);
|
|
|
|
if(!lstrlenA(buf))
|
|
|
|
{
|
|
|
|
skip("Failed to get current directory, skipping tests.\n");
|
|
|
|
return;
|
|
|
|
}
|
2007-12-18 10:00:47 +01:00
|
|
|
|
2010-11-08 00:22:12 +01:00
|
|
|
SHGetDesktopFolder(&psfDesktop);
|
2007-12-18 10:00:47 +01:00
|
|
|
|
2010-11-08 00:22:12 +01:00
|
|
|
/* Attempt BindToObject on files. */
|
|
|
|
|
|
|
|
/* .html */
|
2010-11-28 21:03:09 +01:00
|
|
|
lstrcpyA(pathA, buf);
|
|
|
|
lstrcatA(pathA, "\\");
|
|
|
|
lstrcatA(pathA, filename_html);
|
|
|
|
hfile = CreateFileA(pathA, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
|
|
|
|
if(hfile != INVALID_HANDLE_VALUE)
|
2007-12-18 10:00:47 +01:00
|
|
|
{
|
2010-11-08 00:22:12 +01:00
|
|
|
CloseHandle(hfile);
|
2010-11-28 21:03:09 +01:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, pathA, -1, path, MAX_PATH);
|
2010-11-08 00:22:12 +01:00
|
|
|
hr = IShellFolder_ParseDisplayName(psfDesktop, NULL, NULL, path, NULL, &pidl, NULL);
|
2010-11-28 21:03:09 +01:00
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
2010-11-08 00:22:12 +01:00
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = IShellFolder_BindToObject(psfDesktop, pidl, NULL, &IID_IShellFolder, (void**)&psfChild);
|
2010-11-28 21:03:09 +01:00
|
|
|
ok(hr == S_OK ||
|
|
|
|
hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), /* XP, W2K3 */
|
2010-11-08 00:22:12 +01:00
|
|
|
"Got 0x%08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
IPersist *pp;
|
|
|
|
hr = IShellFolder_QueryInterface(psfChild, &IID_IPersist, (void**)&pp);
|
2010-11-28 21:03:09 +01:00
|
|
|
ok(hr == S_OK ||
|
|
|
|
broken(hr == E_NOINTERFACE), /* Win9x, NT4, W2K */
|
|
|
|
"Got 0x%08x\n", hr);
|
2010-11-08 00:22:12 +01:00
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
CLSID id;
|
|
|
|
hr = IPersist_GetClassID(pp, &id);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
ok(IsEqualIID(&id, &CLSID_ShellDocObjView), "Unexpected classid\n");
|
|
|
|
IPersist_Release(pp);
|
|
|
|
}
|
|
|
|
|
|
|
|
IShellFolder_Release(psfChild);
|
|
|
|
}
|
|
|
|
pILFree(pidl);
|
|
|
|
}
|
2010-11-28 21:03:09 +01:00
|
|
|
DeleteFileA(pathA);
|
2007-12-18 10:00:47 +01:00
|
|
|
}
|
2010-11-08 00:22:12 +01:00
|
|
|
else
|
|
|
|
win_skip("Failed to create .html testfile.\n");
|
|
|
|
|
|
|
|
/* .txt */
|
2010-11-28 21:03:09 +01:00
|
|
|
lstrcpyA(pathA, buf);
|
|
|
|
lstrcatA(pathA, "\\");
|
|
|
|
lstrcatA(pathA, filename_txt);
|
|
|
|
hfile = CreateFileA(pathA, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
|
|
|
|
if(hfile != INVALID_HANDLE_VALUE)
|
2010-11-08 00:22:12 +01:00
|
|
|
{
|
|
|
|
CloseHandle(hfile);
|
2010-11-28 21:03:09 +01:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, pathA, -1, path, MAX_PATH);
|
2010-11-08 00:22:12 +01:00
|
|
|
hr = IShellFolder_ParseDisplayName(psfDesktop, NULL, NULL, path, NULL, &pidl, NULL);
|
2010-11-28 21:03:09 +01:00
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
2010-11-08 00:22:12 +01:00
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = IShellFolder_BindToObject(psfDesktop, pidl, NULL, &IID_IShellFolder, (void**)&psfChild);
|
2010-11-28 21:03:09 +01:00
|
|
|
ok(hr == E_FAIL || /* Vista+ */
|
|
|
|
hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) || /* XP, W2K3 */
|
|
|
|
broken(hr == S_OK), /* Win9x, NT4, W2K */
|
2010-11-08 00:22:12 +01:00
|
|
|
"Got 0x%08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr)) IShellFolder_Release(psfChild);
|
|
|
|
pILFree(pidl);
|
|
|
|
}
|
2010-11-28 21:03:09 +01:00
|
|
|
DeleteFileA(pathA);
|
2010-11-08 00:22:12 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
win_skip("Failed to create .txt testfile.\n");
|
|
|
|
|
|
|
|
/* .foo */
|
2010-11-28 21:03:09 +01:00
|
|
|
lstrcpyA(pathA, buf);
|
|
|
|
lstrcatA(pathA, "\\");
|
|
|
|
lstrcatA(pathA, filename_foo);
|
|
|
|
hfile = CreateFileA(pathA, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
|
|
|
|
if(hfile != INVALID_HANDLE_VALUE)
|
2010-11-08 00:22:12 +01:00
|
|
|
{
|
|
|
|
CloseHandle(hfile);
|
2010-11-28 21:03:09 +01:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, pathA, -1, path, MAX_PATH);
|
2010-11-08 00:22:12 +01:00
|
|
|
hr = IShellFolder_ParseDisplayName(psfDesktop, NULL, NULL, path, NULL, &pidl, NULL);
|
2010-11-28 21:03:09 +01:00
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
2010-11-08 00:22:12 +01:00
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = IShellFolder_BindToObject(psfDesktop, pidl, NULL, &IID_IShellFolder, (void**)&psfChild);
|
2010-11-28 21:03:09 +01:00
|
|
|
ok(hr == E_FAIL || /* Vista+ */
|
|
|
|
hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) || /* XP, W2K3 */
|
|
|
|
broken(hr == S_OK), /* Win9x, NT4, W2K */
|
2010-11-08 00:22:12 +01:00
|
|
|
"Got 0x%08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr)) IShellFolder_Release(psfChild);
|
|
|
|
pILFree(pidl);
|
|
|
|
}
|
2010-11-28 21:03:09 +01:00
|
|
|
DeleteFileA(pathA);
|
2010-11-08 00:22:12 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
win_skip("Failed to create .foo testfile.\n");
|
|
|
|
|
|
|
|
/* And on the desktop */
|
2010-11-28 21:03:09 +01:00
|
|
|
if(pSHGetSpecialFolderPathA)
|
2010-11-08 00:22:12 +01:00
|
|
|
{
|
2010-11-28 21:03:09 +01:00
|
|
|
pSHGetSpecialFolderPathA(NULL, pathA, CSIDL_DESKTOP, FALSE);
|
|
|
|
lstrcatA(pathA, "\\");
|
|
|
|
lstrcatA(pathA, filename_html);
|
|
|
|
hfile = CreateFileA(pathA, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
|
|
|
|
if(hfile != INVALID_HANDLE_VALUE)
|
2010-11-08 00:22:12 +01:00
|
|
|
{
|
|
|
|
CloseHandle(hfile);
|
2010-11-28 21:03:09 +01:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, pathA, -1, path, MAX_PATH);
|
2010-11-08 00:22:12 +01:00
|
|
|
hr = IShellFolder_ParseDisplayName(psfDesktop, NULL, NULL, path, NULL, &pidl, NULL);
|
2010-11-28 21:03:09 +01:00
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
2010-11-08 00:22:12 +01:00
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = IShellFolder_BindToObject(psfDesktop, pidl, NULL, &IID_IShellFolder, (void**)&psfChild);
|
2010-11-28 21:03:09 +01:00
|
|
|
ok(hr == S_OK ||
|
|
|
|
hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), /* XP, W2K3 */
|
2010-11-08 00:22:12 +01:00
|
|
|
"Got 0x%08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr)) IShellFolder_Release(psfChild);
|
|
|
|
pILFree(pidl);
|
|
|
|
}
|
2010-11-28 21:03:09 +01:00
|
|
|
if(!DeleteFileA(pathA))
|
2010-11-08 00:22:12 +01:00
|
|
|
trace("Failed to delete: %d\n", GetLastError());
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
win_skip("Failed to create .html testfile.\n");
|
|
|
|
|
2010-11-28 21:03:09 +01:00
|
|
|
pSHGetSpecialFolderPathA(NULL, pathA, CSIDL_DESKTOP, FALSE);
|
|
|
|
lstrcatA(pathA, "\\");
|
|
|
|
lstrcatA(pathA, filename_foo);
|
|
|
|
hfile = CreateFileA(pathA, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
|
|
|
|
if(hfile != INVALID_HANDLE_VALUE)
|
2010-11-08 00:22:12 +01:00
|
|
|
{
|
|
|
|
CloseHandle(hfile);
|
2010-11-28 21:03:09 +01:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, pathA, -1, path, MAX_PATH);
|
2010-11-08 00:22:12 +01:00
|
|
|
hr = IShellFolder_ParseDisplayName(psfDesktop, NULL, NULL, path, NULL, &pidl, NULL);
|
2010-11-28 21:03:09 +01:00
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
2010-11-08 00:22:12 +01:00
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = IShellFolder_BindToObject(psfDesktop, pidl, NULL, &IID_IShellFolder, (void**)&psfChild);
|
2010-11-28 21:03:09 +01:00
|
|
|
ok(hr == E_FAIL || /* Vista+ */
|
|
|
|
hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) || /* XP, W2K3 */
|
|
|
|
broken(hr == S_OK), /* Win9x, NT4, W2K */
|
2010-11-08 00:22:12 +01:00
|
|
|
"Got 0x%08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr)) IShellFolder_Release(psfChild);
|
|
|
|
pILFree(pidl);
|
|
|
|
}
|
2010-11-28 21:03:09 +01:00
|
|
|
DeleteFileA(pathA);
|
2010-11-08 00:22:12 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
win_skip("Failed to create .foo testfile.\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
IShellFolder_Release(psfDesktop);
|
2007-12-18 10:00:47 +01:00
|
|
|
}
|
|
|
|
|
2005-06-14 19:21:25 +02:00
|
|
|
static void test_GetDisplayName(void)
|
|
|
|
{
|
|
|
|
BOOL result;
|
|
|
|
HRESULT hr;
|
|
|
|
HANDLE hTestFile;
|
2009-01-21 16:44:10 +01:00
|
|
|
WCHAR wszTestFile[MAX_PATH], wszTestFile2[MAX_PATH];
|
2005-08-22 11:14:35 +02:00
|
|
|
char szTestFile[MAX_PATH], szTestDir[MAX_PATH];
|
2007-02-09 12:41:08 +01:00
|
|
|
DWORD attr;
|
2005-06-14 19:21:25 +02:00
|
|
|
STRRET strret;
|
|
|
|
LPSHELLFOLDER psfDesktop, psfPersonal;
|
2005-06-14 20:10:24 +02:00
|
|
|
IUnknown *psfFile;
|
2005-09-07 11:22:49 +02:00
|
|
|
SHITEMID emptyitem = { 0, { 0 } };
|
|
|
|
LPITEMIDLIST pidlTestFile, pidlEmpty = (LPITEMIDLIST)&emptyitem;
|
2005-06-14 19:21:25 +02:00
|
|
|
LPCITEMIDLIST pidlLast;
|
2009-01-21 16:44:10 +01:00
|
|
|
static const CHAR szFileName[] = "winetest.foo";
|
2005-06-14 19:21:25 +02:00
|
|
|
static const WCHAR wszFileName[] = { 'w','i','n','e','t','e','s','t','.','f','o','o',0 };
|
|
|
|
static const WCHAR wszDirName[] = { 'w','i','n','e','t','e','s','t',0 };
|
|
|
|
|
|
|
|
/* I'm trying to figure if there is a functional difference between calling
|
2007-12-18 10:01:05 +01:00
|
|
|
* SHGetPathFromIDListW and calling GetDisplayNameOf(SHGDN_FORPARSING) after
|
2005-06-14 19:21:25 +02:00
|
|
|
* binding to the shellfolder. One thing I thought of was that perhaps
|
2007-12-18 10:01:05 +01:00
|
|
|
* SHGetPathFromIDListW would be able to get the path to a file, which does
|
|
|
|
* not exist anymore, while the other method wouldn't. It turns out there's
|
2005-06-14 19:21:25 +02:00
|
|
|
* no functional difference in this respect.
|
|
|
|
*/
|
|
|
|
|
2009-01-21 16:44:10 +01:00
|
|
|
if(!pSHGetSpecialFolderPathA) {
|
|
|
|
win_skip("SHGetSpecialFolderPathA is not available\n");
|
|
|
|
return;
|
|
|
|
}
|
2005-06-20 12:31:14 +02:00
|
|
|
|
2005-06-14 19:21:25 +02:00
|
|
|
/* First creating a directory in MyDocuments and a file in this directory. */
|
2009-01-21 16:44:10 +01:00
|
|
|
result = pSHGetSpecialFolderPathA(NULL, szTestDir, CSIDL_PERSONAL, FALSE);
|
|
|
|
ok(result, "SHGetSpecialFolderPathA failed! Last error: %u\n", GetLastError());
|
2005-06-14 19:21:25 +02:00
|
|
|
if (!result) return;
|
|
|
|
|
2007-02-09 12:41:08 +01:00
|
|
|
/* Use ANSI file functions so this works on Windows 9x */
|
2009-01-21 16:44:10 +01:00
|
|
|
lstrcatA(szTestDir, "\\winetest");
|
2007-02-09 12:41:08 +01:00
|
|
|
CreateDirectoryA(szTestDir, NULL);
|
|
|
|
attr=GetFileAttributesA(szTestDir);
|
|
|
|
if (attr == INVALID_FILE_ATTRIBUTES || !(attr & FILE_ATTRIBUTE_DIRECTORY))
|
|
|
|
{
|
|
|
|
ok(0, "unable to create the '%s' directory\n", szTestDir);
|
|
|
|
return;
|
|
|
|
}
|
2005-06-14 19:21:25 +02:00
|
|
|
|
2009-01-21 16:44:10 +01:00
|
|
|
lstrcpyA(szTestFile, szTestDir);
|
|
|
|
lstrcatA(szTestFile, "\\");
|
|
|
|
lstrcatA(szTestFile, szFileName);
|
2005-08-22 11:14:35 +02:00
|
|
|
hTestFile = CreateFileA(szTestFile, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
|
2007-01-05 21:48:19 +01:00
|
|
|
ok((hTestFile != INVALID_HANDLE_VALUE), "CreateFileA failed! Last error: %u\n", GetLastError());
|
2005-06-14 19:21:25 +02:00
|
|
|
if (hTestFile == INVALID_HANDLE_VALUE) return;
|
|
|
|
CloseHandle(hTestFile);
|
|
|
|
|
2005-06-17 22:59:49 +02:00
|
|
|
/* Getting an itemidlist for the file. */
|
2005-06-14 19:21:25 +02:00
|
|
|
hr = SHGetDesktopFolder(&psfDesktop);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(hr == S_OK, "SHGetDesktopFolder failed! hr = %08x\n", hr);
|
|
|
|
if (hr != S_OK) return;
|
2005-06-14 19:21:25 +02:00
|
|
|
|
2009-01-21 16:44:10 +01:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, szTestFile, -1, wszTestFile, MAX_PATH);
|
|
|
|
|
2005-06-14 19:21:25 +02:00
|
|
|
hr = IShellFolder_ParseDisplayName(psfDesktop, NULL, NULL, wszTestFile, NULL, &pidlTestFile, NULL);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(hr == S_OK, "Desktop->ParseDisplayName failed! hr = %08x\n", hr);
|
|
|
|
if (hr != S_OK) {
|
2005-06-14 19:21:25 +02:00
|
|
|
IShellFolder_Release(psfDesktop);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-12-12 18:13:14 +01:00
|
|
|
pidlLast = pILFindLastID(pidlTestFile);
|
2009-01-21 16:56:14 +01:00
|
|
|
ok(pidlLast->mkid.cb >=76 ||
|
|
|
|
broken(pidlLast->mkid.cb == 28) || /* W2K */
|
|
|
|
broken(pidlLast->mkid.cb == 40), /* Win9x, WinME */
|
|
|
|
"Expected pidl length of at least 76, got %d.\n", pidlLast->mkid.cb);
|
|
|
|
if (pidlLast->mkid.cb >= 28) {
|
|
|
|
ok(!lstrcmpA((CHAR*)&pidlLast->mkid.abID[12], szFileName),
|
|
|
|
"Filename should be stored as ansi-string at this position!\n");
|
|
|
|
}
|
|
|
|
/* WinXP and up store the filenames as both ANSI and UNICODE in the pidls */
|
2005-12-02 11:25:18 +01:00
|
|
|
if (pidlLast->mkid.cb >= 76) {
|
2009-06-18 10:29:33 +02:00
|
|
|
ok(!lstrcmpW((WCHAR*)&pidlLast->mkid.abID[46], wszFileName) ||
|
2009-11-25 11:15:48 +01:00
|
|
|
(pidlLast->mkid.cb >= 94 && !lstrcmpW((WCHAR*)&pidlLast->mkid.abID[64], wszFileName)) || /* Vista */
|
|
|
|
(pidlLast->mkid.cb >= 98 && !lstrcmpW((WCHAR*)&pidlLast->mkid.abID[68], wszFileName)), /* Win7 */
|
2009-01-21 16:56:14 +01:00
|
|
|
"Filename should be stored as wchar-string at this position!\n");
|
2005-12-02 11:25:18 +01:00
|
|
|
}
|
|
|
|
|
2005-06-17 22:59:49 +02:00
|
|
|
/* It seems as if we cannot bind to regular files on windows, but only directories.
|
2005-06-14 20:10:24 +02:00
|
|
|
*/
|
|
|
|
hr = IShellFolder_BindToObject(psfDesktop, pidlTestFile, NULL, &IID_IUnknown, (VOID**)&psfFile);
|
2009-01-21 16:50:11 +01:00
|
|
|
ok (hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) ||
|
2009-06-18 10:32:41 +02:00
|
|
|
hr == E_NOTIMPL || /* Vista */
|
2010-03-23 02:21:13 +01:00
|
|
|
broken(hr == S_OK), /* Win9x, W2K */
|
2009-01-21 16:50:11 +01:00
|
|
|
"hr = %08x\n", hr);
|
2010-03-23 02:21:13 +01:00
|
|
|
if (hr == S_OK) {
|
2005-06-14 20:10:24 +02:00
|
|
|
IShellFolder_Release(psfFile);
|
|
|
|
}
|
2008-06-10 13:52:58 +02:00
|
|
|
|
2009-04-07 19:15:35 +02:00
|
|
|
if (!pSHBindToParent)
|
2008-06-10 13:52:58 +02:00
|
|
|
{
|
2009-01-21 16:44:10 +01:00
|
|
|
win_skip("SHBindToParent is missing\n");
|
|
|
|
DeleteFileA(szTestFile);
|
|
|
|
RemoveDirectoryA(szTestDir);
|
2008-06-10 13:52:58 +02:00
|
|
|
return;
|
|
|
|
}
|
2006-01-16 20:37:51 +01:00
|
|
|
|
|
|
|
/* Some tests for IShellFolder::SetNameOf */
|
2009-04-07 19:15:35 +02:00
|
|
|
if (pSHGetFolderPathAndSubDirA)
|
|
|
|
{
|
|
|
|
hr = pSHBindToParent(pidlTestFile, &IID_IShellFolder, (VOID**)&psfPersonal, &pidlLast);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(hr == S_OK, "SHBindToParent failed! hr = %08x\n", hr);
|
|
|
|
if (hr == S_OK) {
|
2009-04-07 19:15:35 +02:00
|
|
|
/* It's ok to use this fixed path. Call will fail anyway. */
|
|
|
|
WCHAR wszAbsoluteFilename[] = { 'C',':','\\','w','i','n','e','t','e','s','t', 0 };
|
|
|
|
LPITEMIDLIST pidlNew;
|
|
|
|
|
|
|
|
/* The pidl returned through the last parameter of SetNameOf is a simple one. */
|
|
|
|
hr = IShellFolder_SetNameOf(psfPersonal, NULL, pidlLast, wszDirName, SHGDN_NORMAL, &pidlNew);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok (hr == S_OK, "SetNameOf failed! hr = %08x\n", hr);
|
2009-04-07 19:15:35 +02:00
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
|
|
|
ok (((LPITEMIDLIST)((LPBYTE)pidlNew+pidlNew->mkid.cb))->mkid.cb == 0,
|
|
|
|
"pidl returned from SetNameOf should be simple!\n");
|
|
|
|
|
|
|
|
/* Passing an absolute path to SetNameOf fails. The HRESULT code indicates that SetNameOf
|
|
|
|
* is implemented on top of SHFileOperation in WinXP. */
|
|
|
|
hr = IShellFolder_SetNameOf(psfPersonal, NULL, pidlNew, wszAbsoluteFilename,
|
|
|
|
SHGDN_FORPARSING, NULL);
|
|
|
|
ok (hr == HRESULT_FROM_WIN32(ERROR_CANCELLED), "SetNameOf succeeded! hr = %08x\n", hr);
|
|
|
|
|
|
|
|
/* Rename the file back to its original name. SetNameOf ignores the fact, that the
|
|
|
|
* SHGDN flags specify an absolute path. */
|
|
|
|
hr = IShellFolder_SetNameOf(psfPersonal, NULL, pidlNew, wszFileName, SHGDN_FORPARSING, NULL);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok (hr == S_OK, "SetNameOf failed! hr = %08x\n", hr);
|
2009-04-07 19:15:35 +02:00
|
|
|
|
|
|
|
pILFree(pidlNew);
|
|
|
|
}
|
|
|
|
|
|
|
|
IShellFolder_Release(psfPersonal);
|
2008-06-20 12:35:53 +02:00
|
|
|
}
|
2006-01-16 20:37:51 +01:00
|
|
|
}
|
2009-04-07 19:15:35 +02:00
|
|
|
else
|
|
|
|
win_skip("Avoid needs of interaction on Win2k\n");
|
2007-02-09 12:38:11 +01:00
|
|
|
|
2005-06-14 19:21:25 +02:00
|
|
|
/* Deleting the file and the directory */
|
2005-08-22 11:14:35 +02:00
|
|
|
DeleteFileA(szTestFile);
|
|
|
|
RemoveDirectoryA(szTestDir);
|
2005-06-14 19:21:25 +02:00
|
|
|
|
|
|
|
/* SHGetPathFromIDListW still works, although the file is not present anymore. */
|
2007-12-18 10:01:05 +01:00
|
|
|
if (pSHGetPathFromIDListW)
|
|
|
|
{
|
|
|
|
result = pSHGetPathFromIDListW(pidlTestFile, wszTestFile2);
|
|
|
|
ok (result, "SHGetPathFromIDListW failed! Last error: %u\n", GetLastError());
|
|
|
|
ok (!lstrcmpiW(wszTestFile, wszTestFile2), "SHGetPathFromIDListW returns incorrect path!\n");
|
|
|
|
}
|
2005-06-14 19:21:25 +02:00
|
|
|
|
2005-09-07 11:22:49 +02:00
|
|
|
/* SHBindToParent fails, if called with a NULL PIDL. */
|
|
|
|
hr = pSHBindToParent(NULL, &IID_IShellFolder, (VOID**)&psfPersonal, &pidlLast);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok (hr != S_OK, "SHBindToParent(NULL) should fail!\n");
|
2005-09-07 11:22:49 +02:00
|
|
|
|
|
|
|
/* But it succeeds with an empty PIDL. */
|
|
|
|
hr = pSHBindToParent(pidlEmpty, &IID_IShellFolder, (VOID**)&psfPersonal, &pidlLast);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok (hr == S_OK, "SHBindToParent(empty PIDL) should succeed! hr = %08x\n", hr);
|
2005-09-07 11:22:49 +02:00
|
|
|
ok (pidlLast == pidlEmpty, "The last element of an empty PIDL should be the PIDL itself!\n");
|
2010-03-23 02:21:13 +01:00
|
|
|
if (hr == S_OK)
|
2005-09-07 11:22:49 +02:00
|
|
|
IShellFolder_Release(psfPersonal);
|
|
|
|
|
2005-06-14 19:21:25 +02:00
|
|
|
/* Binding to the folder and querying the display name of the file also works. */
|
2005-06-20 12:31:14 +02:00
|
|
|
hr = pSHBindToParent(pidlTestFile, &IID_IShellFolder, (VOID**)&psfPersonal, &pidlLast);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok (hr == S_OK, "SHBindToParent failed! hr = %08x\n", hr);
|
|
|
|
if (hr != S_OK) {
|
2005-06-14 19:21:25 +02:00
|
|
|
IShellFolder_Release(psfDesktop);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-08-29 23:45:49 +02:00
|
|
|
/* This test shows that Windows doesn't allocate a new pidlLast, but returns a pointer into
|
|
|
|
* pidlTestFile (In accordance with MSDN). */
|
2005-09-07 11:22:49 +02:00
|
|
|
ok (pILFindLastID(pidlTestFile) == pidlLast,
|
|
|
|
"SHBindToParent doesn't return the last id of the pidl param!\n");
|
2005-08-29 23:45:49 +02:00
|
|
|
|
2005-06-14 19:21:25 +02:00
|
|
|
hr = IShellFolder_GetDisplayNameOf(psfPersonal, pidlLast, SHGDN_FORPARSING, &strret);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok (hr == S_OK, "Personal->GetDisplayNameOf failed! hr = %08x\n", hr);
|
|
|
|
if (hr != S_OK) {
|
2005-06-14 19:21:25 +02:00
|
|
|
IShellFolder_Release(psfDesktop);
|
|
|
|
IShellFolder_Release(psfPersonal);
|
|
|
|
return;
|
|
|
|
}
|
2005-08-16 21:29:40 +02:00
|
|
|
|
|
|
|
if (pStrRetToBufW)
|
|
|
|
{
|
|
|
|
hr = pStrRetToBufW(&strret, pidlLast, wszTestFile2, MAX_PATH);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok (hr == S_OK, "StrRetToBufW failed! hr = %08x\n", hr);
|
2005-08-16 21:29:40 +02:00
|
|
|
ok (!lstrcmpiW(wszTestFile, wszTestFile2), "GetDisplayNameOf returns incorrect path!\n");
|
|
|
|
}
|
2005-04-11 20:50:01 +02:00
|
|
|
|
2009-12-16 11:21:55 +01:00
|
|
|
ILFree(pidlTestFile);
|
2005-06-14 19:21:25 +02:00
|
|
|
IShellFolder_Release(psfDesktop);
|
|
|
|
IShellFolder_Release(psfPersonal);
|
|
|
|
}
|
|
|
|
|
2005-06-24 13:33:35 +02:00
|
|
|
static void test_CallForAttributes(void)
|
|
|
|
{
|
|
|
|
HKEY hKey;
|
|
|
|
LONG lResult;
|
|
|
|
HRESULT hr;
|
|
|
|
DWORD dwSize;
|
|
|
|
LPSHELLFOLDER psfDesktop;
|
|
|
|
LPITEMIDLIST pidlMyDocuments;
|
|
|
|
DWORD dwAttributes, dwCallForAttributes, dwOrigAttributes, dwOrigCallForAttributes;
|
|
|
|
static const WCHAR wszAttributes[] = { 'A','t','t','r','i','b','u','t','e','s',0 };
|
|
|
|
static const WCHAR wszCallForAttributes[] = {
|
|
|
|
'C','a','l','l','F','o','r','A','t','t','r','i','b','u','t','e','s',0 };
|
|
|
|
static const WCHAR wszMyDocumentsKey[] = {
|
|
|
|
'C','L','S','I','D','\\','{','4','5','0','D','8','F','B','A','-','A','D','2','5','-',
|
|
|
|
'1','1','D','0','-','9','8','A','8','-','0','8','0','0','3','6','1','B','1','1','0','3','}',
|
|
|
|
'\\','S','h','e','l','l','F','o','l','d','e','r',0 };
|
|
|
|
WCHAR wszMyDocuments[] = {
|
|
|
|
':',':','{','4','5','0','D','8','F','B','A','-','A','D','2','5','-','1','1','D','0','-',
|
|
|
|
'9','8','A','8','-','0','8','0','0','3','6','1','B','1','1','0','3','}',0 };
|
|
|
|
|
|
|
|
/* For the root of a namespace extension, the attributes are not queried by binding
|
|
|
|
* to the object and calling GetAttributesOf. Instead, the attributes are read from
|
|
|
|
* the registry value HKCR/CLSID/{...}/ShellFolder/Attributes. This is documented on MSDN.
|
|
|
|
*
|
|
|
|
* The MyDocuments shellfolder on WinXP has a HKCR/CLSID/{...}/ShellFolder/CallForAttributes
|
|
|
|
* value. It seems that if the folder is queried for one of the flags set in CallForAttributes,
|
|
|
|
* the shell does bind to the folder object and calls GetAttributesOf. This is not documented
|
|
|
|
* on MSDN. This test is meant to document the observed behaviour on WinXP SP2.
|
|
|
|
*/
|
|
|
|
hr = SHGetDesktopFolder(&psfDesktop);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok (hr == S_OK, "SHGetDesktopFolder failed! hr = %08x\n", hr);
|
|
|
|
if (hr != S_OK) return;
|
2005-06-24 13:33:35 +02:00
|
|
|
|
|
|
|
hr = IShellFolder_ParseDisplayName(psfDesktop, NULL, NULL, wszMyDocuments, NULL,
|
|
|
|
&pidlMyDocuments, NULL);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok (hr == S_OK ||
|
2009-04-23 16:21:46 +02:00
|
|
|
broken(hr == E_INVALIDARG), /* Win95, NT4 */
|
2006-10-07 20:18:17 +02:00
|
|
|
"Desktop's ParseDisplayName failed to parse MyDocuments's CLSID! hr = %08x\n", hr);
|
2010-03-23 02:21:13 +01:00
|
|
|
if (hr != S_OK) {
|
2005-06-24 13:33:35 +02:00
|
|
|
IShellFolder_Release(psfDesktop);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
dwAttributes = 0xffffffff;
|
|
|
|
hr = IShellFolder_GetAttributesOf(psfDesktop, 1,
|
|
|
|
(LPCITEMIDLIST*)&pidlMyDocuments, &dwAttributes);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok (hr == S_OK, "Desktop->GetAttributesOf(MyDocuments) failed! hr = %08x\n", hr);
|
2005-06-24 13:33:35 +02:00
|
|
|
|
|
|
|
/* We need the following setup (as observed on WinXP SP2), for the tests to make sense. */
|
2005-09-07 15:28:49 +02:00
|
|
|
ok (dwAttributes & SFGAO_FILESYSTEM, "SFGAO_FILESYSTEM attribute is not set for MyDocuments!\n");
|
2005-06-24 13:33:35 +02:00
|
|
|
ok (!(dwAttributes & SFGAO_ISSLOW), "SFGAO_ISSLOW attribute is set for MyDocuments!\n");
|
|
|
|
ok (!(dwAttributes & SFGAO_GHOSTED), "SFGAO_GHOSTED attribute is set for MyDocuments!\n");
|
|
|
|
|
|
|
|
/* We don't have the MyDocuments shellfolder in wine yet, and thus we don't have the registry
|
|
|
|
* key. So the test will return at this point, if run on wine.
|
|
|
|
*/
|
|
|
|
lResult = RegOpenKeyExW(HKEY_CLASSES_ROOT, wszMyDocumentsKey, 0, KEY_WRITE|KEY_READ, &hKey);
|
2009-12-11 12:56:01 +01:00
|
|
|
ok (lResult == ERROR_SUCCESS ||
|
|
|
|
lResult == ERROR_ACCESS_DENIED,
|
|
|
|
"RegOpenKeyEx failed! result: %08x\n", lResult);
|
2005-06-24 13:33:35 +02:00
|
|
|
if (lResult != ERROR_SUCCESS) {
|
2009-12-11 12:56:01 +01:00
|
|
|
if (lResult == ERROR_ACCESS_DENIED)
|
|
|
|
skip("Not enough rights to open the registry key\n");
|
2005-06-29 13:00:59 +02:00
|
|
|
IMalloc_Free(ppM, pidlMyDocuments);
|
2005-06-24 13:33:35 +02:00
|
|
|
IShellFolder_Release(psfDesktop);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Query MyDocuments' Attributes value, to be able to restore it later. */
|
|
|
|
dwSize = sizeof(DWORD);
|
|
|
|
lResult = RegQueryValueExW(hKey, wszAttributes, NULL, NULL, (LPBYTE)&dwOrigAttributes, &dwSize);
|
2006-10-07 20:18:17 +02:00
|
|
|
ok (lResult == ERROR_SUCCESS, "RegQueryValueEx failed! result: %08x\n", lResult);
|
2005-06-24 13:33:35 +02:00
|
|
|
if (lResult != ERROR_SUCCESS) {
|
|
|
|
RegCloseKey(hKey);
|
2005-06-29 13:00:59 +02:00
|
|
|
IMalloc_Free(ppM, pidlMyDocuments);
|
2005-06-24 13:33:35 +02:00
|
|
|
IShellFolder_Release(psfDesktop);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Query MyDocuments' CallForAttributes value, to be able to restore it later. */
|
|
|
|
dwSize = sizeof(DWORD);
|
|
|
|
lResult = RegQueryValueExW(hKey, wszCallForAttributes, NULL, NULL,
|
|
|
|
(LPBYTE)&dwOrigCallForAttributes, &dwSize);
|
2006-10-07 20:18:17 +02:00
|
|
|
ok (lResult == ERROR_SUCCESS, "RegQueryValueEx failed! result: %08x\n", lResult);
|
2005-06-24 13:33:35 +02:00
|
|
|
if (lResult != ERROR_SUCCESS) {
|
|
|
|
RegCloseKey(hKey);
|
2005-06-29 13:00:59 +02:00
|
|
|
IMalloc_Free(ppM, pidlMyDocuments);
|
2005-06-24 13:33:35 +02:00
|
|
|
IShellFolder_Release(psfDesktop);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Define via the Attributes value that MyDocuments attributes are SFGAO_ISSLOW and
|
|
|
|
* SFGAO_GHOSTED and that MyDocuments should be called for the SFGAO_ISSLOW and
|
|
|
|
* SFGAO_FILESYSTEM attributes. */
|
|
|
|
dwAttributes = SFGAO_ISSLOW|SFGAO_GHOSTED;
|
|
|
|
RegSetValueExW(hKey, wszAttributes, 0, REG_DWORD, (LPBYTE)&dwAttributes, sizeof(DWORD));
|
|
|
|
dwCallForAttributes = SFGAO_ISSLOW|SFGAO_FILESYSTEM;
|
|
|
|
RegSetValueExW(hKey, wszCallForAttributes, 0, REG_DWORD,
|
|
|
|
(LPBYTE)&dwCallForAttributes, sizeof(DWORD));
|
|
|
|
|
|
|
|
/* Although it is not set in CallForAttributes, the SFGAO_GHOSTED flag is reset by
|
|
|
|
* GetAttributesOf. It seems that once there is a single attribute queried, for which
|
|
|
|
* CallForAttributes is set, all flags are taken from the GetAttributesOf call and
|
|
|
|
* the flags in Attributes are ignored.
|
|
|
|
*/
|
|
|
|
dwAttributes = SFGAO_ISSLOW|SFGAO_GHOSTED|SFGAO_FILESYSTEM;
|
|
|
|
hr = IShellFolder_GetAttributesOf(psfDesktop, 1,
|
|
|
|
(LPCITEMIDLIST*)&pidlMyDocuments, &dwAttributes);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok (hr == S_OK, "Desktop->GetAttributesOf(MyDocuments) failed! hr = %08x\n", hr);
|
|
|
|
if (hr == S_OK)
|
2005-06-24 13:33:35 +02:00
|
|
|
ok (dwAttributes == SFGAO_FILESYSTEM,
|
2006-10-07 20:18:17 +02:00
|
|
|
"Desktop->GetAttributes(MyDocuments) returned unexpected attributes: %08x\n",
|
2005-06-24 13:33:35 +02:00
|
|
|
dwAttributes);
|
|
|
|
|
|
|
|
/* Restore MyDocuments' original Attributes and CallForAttributes registry values */
|
|
|
|
RegSetValueExW(hKey, wszAttributes, 0, REG_DWORD, (LPBYTE)&dwOrigAttributes, sizeof(DWORD));
|
|
|
|
RegSetValueExW(hKey, wszCallForAttributes, 0, REG_DWORD,
|
|
|
|
(LPBYTE)&dwOrigCallForAttributes, sizeof(DWORD));
|
|
|
|
RegCloseKey(hKey);
|
2005-06-29 13:00:59 +02:00
|
|
|
IMalloc_Free(ppM, pidlMyDocuments);
|
2005-06-24 13:33:35 +02:00
|
|
|
IShellFolder_Release(psfDesktop);
|
|
|
|
}
|
|
|
|
|
2005-06-14 20:10:24 +02:00
|
|
|
static void test_GetAttributesOf(void)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
2005-06-16 11:44:50 +02:00
|
|
|
LPSHELLFOLDER psfDesktop, psfMyComputer;
|
2005-06-14 20:10:24 +02:00
|
|
|
SHITEMID emptyitem = { 0, { 0 } };
|
|
|
|
LPCITEMIDLIST pidlEmpty = (LPCITEMIDLIST)&emptyitem;
|
2005-06-16 11:44:50 +02:00
|
|
|
LPITEMIDLIST pidlMyComputer;
|
2005-06-14 20:10:24 +02:00
|
|
|
DWORD dwFlags;
|
2009-04-05 22:59:12 +02:00
|
|
|
static const DWORD desktopFlags[] = {
|
|
|
|
/* WinXP */
|
|
|
|
SFGAO_STORAGE | SFGAO_HASPROPSHEET | SFGAO_STORAGEANCESTOR | SFGAO_FILESYSANCESTOR |
|
|
|
|
SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_HASSUBFOLDER,
|
|
|
|
/* Win2k */
|
|
|
|
SFGAO_CANRENAME | SFGAO_HASPROPSHEET | SFGAO_STREAM | SFGAO_FILESYSANCESTOR |
|
|
|
|
SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_HASSUBFOLDER,
|
|
|
|
/* WinMe, Win9x, WinNT*/
|
|
|
|
SFGAO_CANRENAME | SFGAO_HASPROPSHEET | SFGAO_FILESYSANCESTOR |
|
|
|
|
SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_HASSUBFOLDER
|
|
|
|
};
|
|
|
|
static const DWORD myComputerFlags[] = {
|
|
|
|
/* WinXP */
|
|
|
|
SFGAO_CANRENAME | SFGAO_CANDELETE | SFGAO_HASPROPSHEET | SFGAO_DROPTARGET |
|
|
|
|
SFGAO_FILESYSANCESTOR | SFGAO_FOLDER | SFGAO_HASSUBFOLDER,
|
|
|
|
/* Win2k */
|
|
|
|
SFGAO_CANRENAME | SFGAO_HASPROPSHEET | SFGAO_DROPTARGET | SFGAO_STREAM |
|
|
|
|
SFGAO_FILESYSANCESTOR | SFGAO_FOLDER | SFGAO_HASSUBFOLDER,
|
|
|
|
/* WinMe, Win9x, WinNT */
|
|
|
|
SFGAO_CANRENAME | SFGAO_HASPROPSHEET | SFGAO_DROPTARGET | SFGAO_FILESYSANCESTOR |
|
|
|
|
SFGAO_FOLDER | SFGAO_HASSUBFOLDER,
|
|
|
|
/* Win95, WinNT when queried directly */
|
2009-04-06 19:27:06 +02:00
|
|
|
SFGAO_CANLINK | SFGAO_HASPROPSHEET | SFGAO_DROPTARGET | SFGAO_FILESYSANCESTOR |
|
2009-04-05 22:59:12 +02:00
|
|
|
SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_HASSUBFOLDER
|
|
|
|
};
|
2005-06-16 11:44:50 +02:00
|
|
|
WCHAR wszMyComputer[] = {
|
|
|
|
':',':','{','2','0','D','0','4','F','E','0','-','3','A','E','A','-','1','0','6','9','-',
|
|
|
|
'A','2','D','8','-','0','8','0','0','2','B','3','0','3','0','9','D','}',0 };
|
2006-02-11 12:16:56 +01:00
|
|
|
char cCurrDirA [MAX_PATH] = {0};
|
|
|
|
WCHAR cCurrDirW [MAX_PATH];
|
2006-10-29 10:36:57 +01:00
|
|
|
static WCHAR cTestDirW[] = {'t','e','s','t','d','i','r',0};
|
2006-02-11 12:16:56 +01:00
|
|
|
IShellFolder *IDesktopFolder, *testIShellFolder;
|
|
|
|
ITEMIDLIST *newPIDL;
|
2009-04-05 22:59:12 +02:00
|
|
|
int len, i;
|
|
|
|
BOOL foundFlagsMatch;
|
2005-06-16 11:44:50 +02:00
|
|
|
|
2005-06-14 20:10:24 +02:00
|
|
|
hr = SHGetDesktopFolder(&psfDesktop);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok (hr == S_OK, "SHGetDesktopFolder failed! hr = %08x\n", hr);
|
|
|
|
if (hr != S_OK) return;
|
2005-06-14 20:10:24 +02:00
|
|
|
|
|
|
|
/* The Desktop attributes can be queried with a single empty itemidlist, .. */
|
|
|
|
dwFlags = 0xffffffff;
|
|
|
|
hr = IShellFolder_GetAttributesOf(psfDesktop, 1, &pidlEmpty, &dwFlags);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok (hr == S_OK, "Desktop->GetAttributesOf(empty pidl) failed! hr = %08x\n", hr);
|
2009-04-05 22:59:12 +02:00
|
|
|
for (i = 0, foundFlagsMatch = FALSE; !foundFlagsMatch &&
|
|
|
|
i < sizeof(desktopFlags) / sizeof(desktopFlags[0]); i++)
|
|
|
|
{
|
|
|
|
if (desktopFlags[i] == dwFlags)
|
|
|
|
foundFlagsMatch = TRUE;
|
|
|
|
}
|
|
|
|
ok (foundFlagsMatch, "Wrong Desktop attributes: %08x\n", dwFlags);
|
2005-06-14 20:10:24 +02:00
|
|
|
|
|
|
|
/* .. or with no itemidlist at all. */
|
|
|
|
dwFlags = 0xffffffff;
|
|
|
|
hr = IShellFolder_GetAttributesOf(psfDesktop, 0, NULL, &dwFlags);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok (hr == S_OK, "Desktop->GetAttributesOf(NULL) failed! hr = %08x\n", hr);
|
2009-04-05 22:59:12 +02:00
|
|
|
for (i = 0, foundFlagsMatch = FALSE; !foundFlagsMatch &&
|
|
|
|
i < sizeof(desktopFlags) / sizeof(desktopFlags[0]); i++)
|
|
|
|
{
|
|
|
|
if (desktopFlags[i] == dwFlags)
|
|
|
|
foundFlagsMatch = TRUE;
|
|
|
|
}
|
|
|
|
ok (foundFlagsMatch, "Wrong Desktop attributes: %08x\n", dwFlags);
|
2005-06-16 11:44:50 +02:00
|
|
|
|
|
|
|
/* Testing the attributes of the MyComputer shellfolder */
|
|
|
|
hr = IShellFolder_ParseDisplayName(psfDesktop, NULL, NULL, wszMyComputer, NULL, &pidlMyComputer, NULL);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok (hr == S_OK, "Desktop's ParseDisplayName failed to parse MyComputer's CLSID! hr = %08x\n", hr);
|
|
|
|
if (hr != S_OK) {
|
2005-06-16 11:44:50 +02:00
|
|
|
IShellFolder_Release(psfDesktop);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-04-05 22:59:12 +02:00
|
|
|
/* Windows sets the SFGAO_CANLINK flag, when MyComputer is queried via the Desktop
|
2005-06-16 11:44:50 +02:00
|
|
|
* folder object. It doesn't do this, if MyComputer is queried directly (see below).
|
|
|
|
*/
|
|
|
|
dwFlags = 0xffffffff;
|
|
|
|
hr = IShellFolder_GetAttributesOf(psfDesktop, 1, (LPCITEMIDLIST*)&pidlMyComputer, &dwFlags);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok (hr == S_OK, "Desktop->GetAttributesOf(MyComputer) failed! hr = %08x\n", hr);
|
2009-04-05 22:59:12 +02:00
|
|
|
for (i = 0, foundFlagsMatch = FALSE; !foundFlagsMatch &&
|
|
|
|
i < sizeof(myComputerFlags) / sizeof(myComputerFlags[0]); i++)
|
|
|
|
{
|
2009-04-06 19:56:45 +02:00
|
|
|
if ((myComputerFlags[i] | SFGAO_CANLINK) == dwFlags)
|
2009-04-05 22:59:12 +02:00
|
|
|
foundFlagsMatch = TRUE;
|
|
|
|
}
|
2009-04-06 19:56:45 +02:00
|
|
|
todo_wine
|
2009-04-05 22:59:12 +02:00
|
|
|
ok (foundFlagsMatch, "Wrong MyComputer attributes: %08x\n", dwFlags);
|
2005-06-16 11:44:50 +02:00
|
|
|
|
|
|
|
hr = IShellFolder_BindToObject(psfDesktop, pidlMyComputer, NULL, &IID_IShellFolder, (LPVOID*)&psfMyComputer);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok (hr == S_OK, "Desktop failed to bind to MyComputer object! hr = %08x\n", hr);
|
2005-06-14 20:10:24 +02:00
|
|
|
IShellFolder_Release(psfDesktop);
|
2005-06-29 13:00:59 +02:00
|
|
|
IMalloc_Free(ppM, pidlMyComputer);
|
2010-03-23 02:21:13 +01:00
|
|
|
if (hr != S_OK) return;
|
2005-06-16 11:44:50 +02:00
|
|
|
|
|
|
|
hr = IShellFolder_GetAttributesOf(psfMyComputer, 1, &pidlEmpty, &dwFlags);
|
2009-03-12 12:06:04 +01:00
|
|
|
todo_wine
|
|
|
|
ok (hr == E_INVALIDARG ||
|
2010-03-23 02:21:13 +01:00
|
|
|
broken(hr == S_OK), /* W2K and earlier */
|
2009-03-12 12:06:04 +01:00
|
|
|
"MyComputer->GetAttributesOf(emtpy pidl) should fail! hr = %08x\n", hr);
|
2005-06-16 11:44:50 +02:00
|
|
|
|
|
|
|
dwFlags = 0xffffffff;
|
|
|
|
hr = IShellFolder_GetAttributesOf(psfMyComputer, 0, NULL, &dwFlags);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok (hr == S_OK, "MyComputer->GetAttributesOf(NULL) failed! hr = %08x\n", hr);
|
2009-04-05 22:59:12 +02:00
|
|
|
for (i = 0, foundFlagsMatch = FALSE; !foundFlagsMatch &&
|
|
|
|
i < sizeof(myComputerFlags) / sizeof(myComputerFlags[0]); i++)
|
|
|
|
{
|
|
|
|
if (myComputerFlags[i] == dwFlags)
|
|
|
|
foundFlagsMatch = TRUE;
|
|
|
|
}
|
|
|
|
todo_wine
|
|
|
|
ok (foundFlagsMatch, "Wrong MyComputer attributes: %08x\n", dwFlags);
|
2005-06-16 11:44:50 +02:00
|
|
|
|
|
|
|
IShellFolder_Release(psfMyComputer);
|
2006-02-11 12:16:56 +01:00
|
|
|
|
|
|
|
GetCurrentDirectoryA(MAX_PATH, cCurrDirA);
|
|
|
|
len = lstrlenA(cCurrDirA);
|
|
|
|
|
|
|
|
if (len == 0) {
|
2009-04-05 22:59:12 +02:00
|
|
|
win_skip("GetCurrentDirectoryA returned empty string. Skipping test_GetAttributesOf\n");
|
|
|
|
return;
|
2006-02-11 12:16:56 +01:00
|
|
|
}
|
2009-04-05 23:01:35 +02:00
|
|
|
if (len > 3 && cCurrDirA[len-1] == '\\')
|
|
|
|
cCurrDirA[len-1] = 0;
|
2006-02-11 12:16:56 +01:00
|
|
|
|
2009-03-04 21:53:16 +01:00
|
|
|
/* create test directory */
|
|
|
|
CreateFilesFolders();
|
|
|
|
|
2006-02-11 12:16:56 +01:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, cCurrDirA, -1, cCurrDirW, MAX_PATH);
|
|
|
|
|
|
|
|
hr = SHGetDesktopFolder(&IDesktopFolder);
|
2006-10-07 20:18:17 +02:00
|
|
|
ok(hr == S_OK, "SHGetDesktopfolder failed %08x\n", hr);
|
2006-02-11 12:16:56 +01:00
|
|
|
|
|
|
|
hr = IShellFolder_ParseDisplayName(IDesktopFolder, NULL, NULL, cCurrDirW, NULL, &newPIDL, 0);
|
2006-10-07 20:18:17 +02:00
|
|
|
ok(hr == S_OK, "ParseDisplayName failed %08x\n", hr);
|
2006-02-11 12:16:56 +01:00
|
|
|
|
|
|
|
hr = IShellFolder_BindToObject(IDesktopFolder, newPIDL, NULL, (REFIID)&IID_IShellFolder, (LPVOID *)&testIShellFolder);
|
2006-10-07 20:18:17 +02:00
|
|
|
ok(hr == S_OK, "BindToObject failed %08x\n", hr);
|
2006-02-11 12:16:56 +01:00
|
|
|
|
|
|
|
IMalloc_Free(ppM, newPIDL);
|
|
|
|
|
|
|
|
/* get relative PIDL */
|
2006-10-29 10:36:57 +01:00
|
|
|
hr = IShellFolder_ParseDisplayName(testIShellFolder, NULL, NULL, cTestDirW, NULL, &newPIDL, 0);
|
2006-10-07 20:18:17 +02:00
|
|
|
ok(hr == S_OK, "ParseDisplayName failed %08x\n", hr);
|
2006-02-11 12:16:56 +01:00
|
|
|
|
|
|
|
/* test the shell attributes of the test directory using the relative PIDL */
|
|
|
|
dwFlags = SFGAO_FOLDER;
|
|
|
|
hr = IShellFolder_GetAttributesOf(testIShellFolder, 1, (LPCITEMIDLIST*)&newPIDL, &dwFlags);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok (hr == S_OK, "Desktop->GetAttributesOf() failed! hr = %08x\n", hr);
|
2006-10-07 20:18:17 +02:00
|
|
|
ok ((dwFlags&SFGAO_FOLDER), "Wrong directory attribute for relative PIDL: %08x\n", dwFlags);
|
2006-02-11 12:16:56 +01:00
|
|
|
|
|
|
|
/* free memory */
|
|
|
|
IMalloc_Free(ppM, newPIDL);
|
|
|
|
|
|
|
|
/* append testdirectory name to path */
|
2009-04-07 19:14:07 +02:00
|
|
|
if (cCurrDirA[len-1] == '\\')
|
|
|
|
cCurrDirA[len-1] = 0;
|
2009-03-04 21:53:16 +01:00
|
|
|
lstrcatA(cCurrDirA, "\\testdir");
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, cCurrDirA, -1, cCurrDirW, MAX_PATH);
|
2006-02-11 12:16:56 +01:00
|
|
|
|
|
|
|
hr = IShellFolder_ParseDisplayName(IDesktopFolder, NULL, NULL, cCurrDirW, NULL, &newPIDL, 0);
|
2006-10-07 20:18:17 +02:00
|
|
|
ok(hr == S_OK, "ParseDisplayName failed %08x\n", hr);
|
2006-02-11 12:16:56 +01:00
|
|
|
|
|
|
|
/* test the shell attributes of the test directory using the absolute PIDL */
|
|
|
|
dwFlags = SFGAO_FOLDER;
|
|
|
|
hr = IShellFolder_GetAttributesOf(IDesktopFolder, 1, (LPCITEMIDLIST*)&newPIDL, &dwFlags);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok (hr == S_OK, "Desktop->GetAttributesOf() failed! hr = %08x\n", hr);
|
2006-10-07 20:18:17 +02:00
|
|
|
ok ((dwFlags&SFGAO_FOLDER), "Wrong directory attribute for absolute PIDL: %08x\n", dwFlags);
|
2009-04-05 23:01:35 +02:00
|
|
|
|
2006-02-11 12:16:56 +01:00
|
|
|
/* free memory */
|
|
|
|
IMalloc_Free(ppM, newPIDL);
|
|
|
|
|
2006-02-24 22:24:12 +01:00
|
|
|
IShellFolder_Release(testIShellFolder);
|
2006-02-11 12:16:56 +01:00
|
|
|
|
|
|
|
Cleanup();
|
|
|
|
|
2006-02-24 22:24:12 +01:00
|
|
|
IShellFolder_Release(IDesktopFolder);
|
2009-04-05 23:01:35 +02:00
|
|
|
}
|
2005-06-14 20:10:24 +02:00
|
|
|
|
2005-06-15 20:07:55 +02:00
|
|
|
static void test_SHGetPathFromIDList(void)
|
|
|
|
{
|
|
|
|
SHITEMID emptyitem = { 0, { 0 } };
|
|
|
|
LPCITEMIDLIST pidlEmpty = (LPCITEMIDLIST)&emptyitem;
|
|
|
|
LPITEMIDLIST pidlMyComputer;
|
|
|
|
WCHAR wszPath[MAX_PATH], wszDesktop[MAX_PATH];
|
|
|
|
BOOL result;
|
|
|
|
HRESULT hr;
|
|
|
|
LPSHELLFOLDER psfDesktop;
|
|
|
|
WCHAR wszMyComputer[] = {
|
|
|
|
':',':','{','2','0','D','0','4','F','E','0','-','3','A','E','A','-','1','0','6','9','-',
|
|
|
|
'A','2','D','8','-','0','8','0','0','2','B','3','0','3','0','9','D','}',0 };
|
2005-08-15 11:40:45 +02:00
|
|
|
WCHAR wszFileName[MAX_PATH];
|
|
|
|
LPITEMIDLIST pidlTestFile;
|
|
|
|
HANDLE hTestFile;
|
|
|
|
STRRET strret;
|
|
|
|
static WCHAR wszTestFile[] = {
|
|
|
|
'w','i','n','e','t','e','s','t','.','f','o','o',0 };
|
2010-07-22 20:17:02 +02:00
|
|
|
LPITEMIDLIST pidlPrograms;
|
2005-06-15 20:07:55 +02:00
|
|
|
|
2007-12-18 10:01:05 +01:00
|
|
|
if(!pSHGetPathFromIDListW || !pSHGetSpecialFolderPathW)
|
|
|
|
{
|
2009-03-04 21:55:11 +01:00
|
|
|
win_skip("SHGetPathFromIDListW() or SHGetSpecialFolderPathW() is missing\n");
|
2007-12-18 10:01:05 +01:00
|
|
|
return;
|
|
|
|
}
|
2005-06-20 12:31:14 +02:00
|
|
|
|
2007-12-18 10:01:05 +01:00
|
|
|
/* Calling SHGetPathFromIDListW with no pidl should return the empty string */
|
2006-07-11 05:11:09 +02:00
|
|
|
wszPath[0] = 'a';
|
|
|
|
wszPath[1] = '\0';
|
2007-12-18 10:01:05 +01:00
|
|
|
result = pSHGetPathFromIDListW(NULL, wszPath);
|
2006-07-11 05:11:09 +02:00
|
|
|
ok(!result, "Expected failure\n");
|
|
|
|
ok(!wszPath[0], "Expected empty string\n");
|
|
|
|
|
2007-12-18 10:01:05 +01:00
|
|
|
/* Calling SHGetPathFromIDListW with an empty pidl should return the desktop folder's path. */
|
2005-06-20 12:31:14 +02:00
|
|
|
result = pSHGetSpecialFolderPathW(NULL, wszDesktop, CSIDL_DESKTOP, FALSE);
|
2007-01-05 21:48:19 +01:00
|
|
|
ok(result, "SHGetSpecialFolderPathW(CSIDL_DESKTOP) failed! Last error: %u\n", GetLastError());
|
2005-06-15 20:07:55 +02:00
|
|
|
if (!result) return;
|
2009-03-04 21:55:11 +01:00
|
|
|
|
|
|
|
/* Check if we are on Win9x */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
lstrcmpiW(wszDesktop, wszDesktop);
|
|
|
|
if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
|
|
|
|
{
|
|
|
|
win_skip("Most W-calls are not implemented\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-12-18 10:01:05 +01:00
|
|
|
result = pSHGetPathFromIDListW(pidlEmpty, wszPath);
|
2007-01-05 21:48:19 +01:00
|
|
|
ok(result, "SHGetPathFromIDListW failed! Last error: %u\n", GetLastError());
|
2005-06-15 20:07:55 +02:00
|
|
|
if (!result) return;
|
2007-12-18 10:01:05 +01:00
|
|
|
ok(!lstrcmpiW(wszDesktop, wszPath), "SHGetPathFromIDListW didn't return desktop path for empty pidl!\n");
|
2005-06-15 20:07:55 +02:00
|
|
|
|
2007-12-18 10:01:05 +01:00
|
|
|
/* MyComputer does not map to a filesystem path. SHGetPathFromIDListW should fail. */
|
2005-06-15 20:07:55 +02:00
|
|
|
hr = SHGetDesktopFolder(&psfDesktop);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok (hr == S_OK, "SHGetDesktopFolder failed! hr = %08x\n", hr);
|
|
|
|
if (hr != S_OK) return;
|
2005-06-15 20:07:55 +02:00
|
|
|
|
|
|
|
hr = IShellFolder_ParseDisplayName(psfDesktop, NULL, NULL, wszMyComputer, NULL, &pidlMyComputer, NULL);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok (hr == S_OK, "Desktop's ParseDisplayName failed to parse MyComputer's CLSID! hr = %08x\n", hr);
|
|
|
|
if (hr != S_OK) {
|
2005-08-15 11:40:45 +02:00
|
|
|
IShellFolder_Release(psfDesktop);
|
|
|
|
return;
|
|
|
|
}
|
2005-06-15 20:07:55 +02:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2006-07-11 05:11:09 +02:00
|
|
|
wszPath[0] = 'a';
|
|
|
|
wszPath[1] = '\0';
|
2007-12-18 10:01:05 +01:00
|
|
|
result = pSHGetPathFromIDListW(pidlMyComputer, wszPath);
|
|
|
|
ok (!result, "SHGetPathFromIDListW succeeded where it shouldn't!\n");
|
2009-06-18 10:45:44 +02:00
|
|
|
ok (GetLastError()==0xdeadbeef ||
|
|
|
|
GetLastError()==ERROR_SUCCESS, /* Vista and higher */
|
|
|
|
"Unexpected last error from SHGetPathFromIDListW: %u\n", GetLastError());
|
2006-07-11 05:11:09 +02:00
|
|
|
ok (!wszPath[0], "Expected empty path\n");
|
2005-08-15 11:40:45 +02:00
|
|
|
if (result) {
|
|
|
|
IShellFolder_Release(psfDesktop);
|
|
|
|
return;
|
|
|
|
}
|
2005-06-15 20:07:55 +02:00
|
|
|
|
2005-06-29 13:00:59 +02:00
|
|
|
IMalloc_Free(ppM, pidlMyComputer);
|
2005-08-15 11:40:45 +02:00
|
|
|
|
|
|
|
result = pSHGetSpecialFolderPathW(NULL, wszFileName, CSIDL_DESKTOPDIRECTORY, FALSE);
|
2007-01-05 21:48:19 +01:00
|
|
|
ok(result, "SHGetSpecialFolderPathW failed! Last error: %u\n", GetLastError());
|
2005-08-15 11:40:45 +02:00
|
|
|
if (!result) {
|
|
|
|
IShellFolder_Release(psfDesktop);
|
|
|
|
return;
|
|
|
|
}
|
2007-12-18 10:00:47 +01:00
|
|
|
myPathAddBackslashW(wszFileName);
|
2005-08-15 11:40:45 +02:00
|
|
|
lstrcatW(wszFileName, wszTestFile);
|
|
|
|
hTestFile = CreateFileW(wszFileName, GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, NULL);
|
2007-01-05 21:48:19 +01:00
|
|
|
ok(hTestFile != INVALID_HANDLE_VALUE, "CreateFileW failed! Last error: %u\n", GetLastError());
|
2005-08-15 11:40:45 +02:00
|
|
|
if (hTestFile == INVALID_HANDLE_VALUE) {
|
|
|
|
IShellFolder_Release(psfDesktop);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
CloseHandle(hTestFile);
|
|
|
|
|
|
|
|
hr = IShellFolder_ParseDisplayName(psfDesktop, NULL, NULL, wszTestFile, NULL, &pidlTestFile, NULL);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok (hr == S_OK, "Desktop's ParseDisplayName failed to parse filename hr = %08x\n", hr);
|
|
|
|
if (hr != S_OK) {
|
2005-08-15 11:40:45 +02:00
|
|
|
IShellFolder_Release(psfDesktop);
|
|
|
|
DeleteFileW(wszFileName);
|
|
|
|
IMalloc_Free(ppM, pidlTestFile);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This test is to show that the Desktop shellfolder prepends the CSIDL_DESKTOPDIRECTORY
|
|
|
|
* path for files placed on the desktop, if called with SHGDN_FORPARSING. */
|
|
|
|
hr = IShellFolder_GetDisplayNameOf(psfDesktop, pidlTestFile, SHGDN_FORPARSING, &strret);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok (hr == S_OK, "Desktop's GetDisplayNamfOf failed! hr = %08x\n", hr);
|
2005-08-15 11:40:45 +02:00
|
|
|
IShellFolder_Release(psfDesktop);
|
|
|
|
DeleteFileW(wszFileName);
|
2010-03-23 02:21:13 +01:00
|
|
|
if (hr != S_OK) {
|
2005-08-15 11:40:45 +02:00
|
|
|
IMalloc_Free(ppM, pidlTestFile);
|
|
|
|
return;
|
|
|
|
}
|
2005-08-16 21:29:40 +02:00
|
|
|
if (pStrRetToBufW)
|
|
|
|
{
|
|
|
|
pStrRetToBufW(&strret, pidlTestFile, wszPath, MAX_PATH);
|
|
|
|
ok(0 == lstrcmpW(wszFileName, wszPath),
|
|
|
|
"Desktop->GetDisplayNameOf(pidlTestFile, SHGDN_FORPARSING) "
|
|
|
|
"returned incorrect path for file placed on desktop\n");
|
|
|
|
}
|
2005-08-15 11:40:45 +02:00
|
|
|
|
2007-12-18 10:01:05 +01:00
|
|
|
result = pSHGetPathFromIDListW(pidlTestFile, wszPath);
|
2007-01-05 21:48:19 +01:00
|
|
|
ok(result, "SHGetPathFromIDListW failed! Last error: %u\n", GetLastError());
|
2005-08-15 11:40:45 +02:00
|
|
|
IMalloc_Free(ppM, pidlTestFile);
|
|
|
|
if (!result) return;
|
|
|
|
ok(0 == lstrcmpW(wszFileName, wszPath), "SHGetPathFromIDListW returned incorrect path for file placed on desktop\n");
|
2005-11-28 10:38:06 +01:00
|
|
|
|
|
|
|
|
2010-07-22 20:17:02 +02:00
|
|
|
/* Test if we can get the path from the start menu "program files" PIDL. */
|
2005-11-28 10:38:06 +01:00
|
|
|
hr = pSHGetSpecialFolderLocation(NULL, CSIDL_PROGRAM_FILES, &pidlPrograms);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(hr == S_OK, "SHGetFolderLocation failed: 0x%08x\n", hr);
|
2005-11-28 10:38:06 +01:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2007-12-18 10:01:05 +01:00
|
|
|
result = pSHGetPathFromIDListW(pidlPrograms, wszPath);
|
2005-11-28 10:38:06 +01:00
|
|
|
IMalloc_Free(ppM, pidlPrograms);
|
2007-12-18 10:01:05 +01:00
|
|
|
ok(result, "SHGetPathFromIDListW failed\n");
|
2005-06-15 20:07:55 +02:00
|
|
|
}
|
|
|
|
|
2005-06-21 22:04:17 +02:00
|
|
|
static void test_EnumObjects_and_CompareIDs(void)
|
2004-09-14 01:25:09 +02:00
|
|
|
{
|
|
|
|
ITEMIDLIST *newPIDL;
|
|
|
|
IShellFolder *IDesktopFolder, *testIShellFolder;
|
2005-06-09 14:05:50 +02:00
|
|
|
char cCurrDirA [MAX_PATH] = {0};
|
2009-03-04 21:18:58 +01:00
|
|
|
static const CHAR cTestDirA[] = "\\testdir";
|
|
|
|
WCHAR cTestDirW[MAX_PATH];
|
2005-08-08 20:03:47 +02:00
|
|
|
int len;
|
2005-04-11 20:50:01 +02:00
|
|
|
HRESULT hr;
|
2005-06-20 12:31:14 +02:00
|
|
|
|
2005-06-09 14:05:50 +02:00
|
|
|
GetCurrentDirectoryA(MAX_PATH, cCurrDirA);
|
2005-08-08 20:03:47 +02:00
|
|
|
len = lstrlenA(cCurrDirA);
|
|
|
|
|
|
|
|
if(len == 0) {
|
2009-03-04 21:18:58 +01:00
|
|
|
win_skip("GetCurrentDirectoryA returned empty string. Skipping test_EnumObjects_and_CompareIDs\n");
|
2005-08-08 20:03:47 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(cCurrDirA[len-1] == '\\')
|
|
|
|
cCurrDirA[len-1] = 0;
|
|
|
|
|
2009-03-04 21:18:58 +01:00
|
|
|
lstrcatA(cCurrDirA, cTestDirA);
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, cCurrDirA, -1, cTestDirW, MAX_PATH);
|
2004-09-14 01:25:09 +02:00
|
|
|
|
2005-04-11 20:50:01 +02:00
|
|
|
hr = SHGetDesktopFolder(&IDesktopFolder);
|
2006-10-07 20:18:17 +02:00
|
|
|
ok(hr == S_OK, "SHGetDesktopfolder failed %08x\n", hr);
|
2004-09-14 01:25:09 +02:00
|
|
|
|
2005-06-22 20:04:04 +02:00
|
|
|
CreateFilesFolders();
|
|
|
|
|
2009-03-04 21:18:58 +01:00
|
|
|
hr = IShellFolder_ParseDisplayName(IDesktopFolder, NULL, NULL, cTestDirW, NULL, &newPIDL, 0);
|
2006-10-07 20:18:17 +02:00
|
|
|
ok(hr == S_OK, "ParseDisplayName failed %08x\n", hr);
|
2004-09-14 01:25:09 +02:00
|
|
|
|
2005-04-11 20:50:01 +02:00
|
|
|
hr = IShellFolder_BindToObject(IDesktopFolder, newPIDL, NULL, (REFIID)&IID_IShellFolder, (LPVOID *)&testIShellFolder);
|
2006-10-07 20:18:17 +02:00
|
|
|
ok(hr == S_OK, "BindToObject failed %08x\n", hr);
|
2005-06-22 20:04:04 +02:00
|
|
|
|
2005-04-11 20:50:01 +02:00
|
|
|
test_EnumObjects(testIShellFolder);
|
|
|
|
|
2006-02-24 22:24:12 +01:00
|
|
|
IShellFolder_Release(testIShellFolder);
|
2005-04-11 20:50:01 +02:00
|
|
|
|
2004-09-14 01:25:09 +02:00
|
|
|
Cleanup();
|
2005-06-22 20:04:04 +02:00
|
|
|
|
|
|
|
IMalloc_Free(ppM, newPIDL);
|
2006-02-11 12:16:56 +01:00
|
|
|
|
2006-02-24 22:24:12 +01:00
|
|
|
IShellFolder_Release(IDesktopFolder);
|
2004-09-14 01:25:09 +02:00
|
|
|
}
|
2005-06-21 22:04:17 +02:00
|
|
|
|
2005-08-23 11:37:59 +02:00
|
|
|
/* A simple implementation of an IPropertyBag, which returns fixed values for
|
|
|
|
* 'Target' and 'Attributes' properties.
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI InitPropertyBag_IPropertyBag_QueryInterface(IPropertyBag *iface, REFIID riid,
|
|
|
|
void **ppvObject)
|
|
|
|
{
|
|
|
|
if (!ppvObject)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if (IsEqualIID(&IID_IUnknown, riid) || IsEqualIID(&IID_IPropertyBag, riid)) {
|
|
|
|
*ppvObject = iface;
|
|
|
|
} else {
|
|
|
|
ok (FALSE, "InitPropertyBag asked for unknown interface!\n");
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
IPropertyBag_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI InitPropertyBag_IPropertyBag_AddRef(IPropertyBag *iface) {
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI InitPropertyBag_IPropertyBag_Release(IPropertyBag *iface) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI InitPropertyBag_IPropertyBag_Read(IPropertyBag *iface, LPCOLESTR pszPropName,
|
|
|
|
VARIANT *pVar, IErrorLog *pErrorLog)
|
|
|
|
{
|
|
|
|
static const WCHAR wszTargetSpecialFolder[] = {
|
|
|
|
'T','a','r','g','e','t','S','p','e','c','i','a','l','F','o','l','d','e','r',0 };
|
|
|
|
static const WCHAR wszTarget[] = {
|
|
|
|
'T','a','r','g','e','t',0 };
|
|
|
|
static const WCHAR wszAttributes[] = {
|
|
|
|
'A','t','t','r','i','b','u','t','e','s',0 };
|
|
|
|
static const WCHAR wszResolveLinkFlags[] = {
|
|
|
|
'R','e','s','o','l','v','e','L','i','n','k','F','l','a','g','s',0 };
|
2009-06-18 11:03:19 +02:00
|
|
|
static const WCHAR wszTargetKnownFolder[] = {
|
|
|
|
'T','a','r','g','e','t','K','n','o','w','n','F','o','l','d','e','r',0 };
|
|
|
|
static const WCHAR wszCLSID[] = {
|
|
|
|
'C','L','S','I','D',0 };
|
2005-11-03 13:04:24 +01:00
|
|
|
|
|
|
|
if (!lstrcmpW(pszPropName, wszTargetSpecialFolder)) {
|
2009-04-07 19:16:46 +02:00
|
|
|
ok(V_VT(pVar) == VT_I4 ||
|
|
|
|
broken(V_VT(pVar) == VT_BSTR), /* Win2k */
|
|
|
|
"Wrong variant type for 'TargetSpecialFolder' property!\n");
|
2005-11-03 13:04:24 +01:00
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!lstrcmpW(pszPropName, wszResolveLinkFlags))
|
2005-08-23 11:37:59 +02:00
|
|
|
{
|
2005-11-03 13:04:24 +01:00
|
|
|
ok(V_VT(pVar) == VT_UI4, "Wrong variant type for 'ResolveLinkFlags' property!\n");
|
2005-08-23 11:37:59 +02:00
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!lstrcmpW(pszPropName, wszTarget)) {
|
|
|
|
WCHAR wszPath[MAX_PATH];
|
|
|
|
BOOL result;
|
|
|
|
|
2009-04-07 19:16:46 +02:00
|
|
|
ok(V_VT(pVar) == VT_BSTR ||
|
|
|
|
broken(V_VT(pVar) == VT_EMPTY), /* Win2k */
|
|
|
|
"Wrong variant type for 'Target' property!\n");
|
2005-08-23 11:37:59 +02:00
|
|
|
if (V_VT(pVar) != VT_BSTR) return E_INVALIDARG;
|
|
|
|
|
|
|
|
result = pSHGetSpecialFolderPathW(NULL, wszPath, CSIDL_DESKTOPDIRECTORY, FALSE);
|
2007-01-05 21:48:19 +01:00
|
|
|
ok(result, "SHGetSpecialFolderPathW(DESKTOPDIRECTORY) failed! %u\n", GetLastError());
|
2005-08-23 11:37:59 +02:00
|
|
|
if (!result) return E_INVALIDARG;
|
|
|
|
|
|
|
|
V_BSTR(pVar) = SysAllocString(wszPath);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!lstrcmpW(pszPropName, wszAttributes)) {
|
|
|
|
ok(V_VT(pVar) == VT_UI4, "Wrong variant type for 'Attributes' property!\n");
|
|
|
|
if (V_VT(pVar) != VT_UI4) return E_INVALIDARG;
|
|
|
|
V_UI4(pVar) = SFGAO_FOLDER|SFGAO_HASSUBFOLDER|SFGAO_FILESYSANCESTOR|
|
|
|
|
SFGAO_CANRENAME|SFGAO_FILESYSTEM;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2009-06-18 11:03:19 +02:00
|
|
|
if (!lstrcmpW(pszPropName, wszTargetKnownFolder)) {
|
|
|
|
ok(V_VT(pVar) == VT_BSTR, "Wrong variant type for 'TargetKnownFolder' property!\n");
|
|
|
|
/* TODO */
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!lstrcmpW(pszPropName, wszCLSID)) {
|
|
|
|
ok(V_VT(pVar) == VT_EMPTY, "Wrong variant type for 'CLSID' property!\n");
|
|
|
|
/* TODO */
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
ok(FALSE, "PropertyBag was asked for unknown property %s (vt=%d)!\n", wine_dbgstr_w(pszPropName), V_VT(pVar));
|
2005-08-23 11:37:59 +02:00
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI InitPropertyBag_IPropertyBag_Write(IPropertyBag *iface, LPCOLESTR pszPropName,
|
|
|
|
VARIANT *pVar)
|
|
|
|
{
|
|
|
|
ok(FALSE, "Unexpected call to IPropertyBag_Write\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IPropertyBagVtbl InitPropertyBag_IPropertyBagVtbl = {
|
|
|
|
InitPropertyBag_IPropertyBag_QueryInterface,
|
|
|
|
InitPropertyBag_IPropertyBag_AddRef,
|
|
|
|
InitPropertyBag_IPropertyBag_Release,
|
|
|
|
InitPropertyBag_IPropertyBag_Read,
|
|
|
|
InitPropertyBag_IPropertyBag_Write
|
|
|
|
};
|
|
|
|
|
2006-12-10 16:51:26 +01:00
|
|
|
static struct IPropertyBag InitPropertyBag = {
|
2005-08-23 11:37:59 +02:00
|
|
|
&InitPropertyBag_IPropertyBagVtbl
|
|
|
|
};
|
|
|
|
|
2006-12-10 16:51:26 +01:00
|
|
|
static void test_FolderShortcut(void) {
|
2005-08-23 11:37:59 +02:00
|
|
|
IPersistPropertyBag *pPersistPropertyBag;
|
2005-11-03 13:04:24 +01:00
|
|
|
IShellFolder *pShellFolder, *pDesktopFolder;
|
2005-08-23 11:37:59 +02:00
|
|
|
IPersistFolder3 *pPersistFolder3;
|
|
|
|
HRESULT hr;
|
|
|
|
STRRET strret;
|
2005-11-03 13:04:24 +01:00
|
|
|
WCHAR wszDesktopPath[MAX_PATH], wszBuffer[MAX_PATH];
|
2005-08-23 11:37:59 +02:00
|
|
|
BOOL result;
|
|
|
|
CLSID clsid;
|
2005-11-03 13:04:24 +01:00
|
|
|
LPITEMIDLIST pidlCurrentFolder, pidlWineTestFolder, pidlSubFolder;
|
2005-12-20 11:57:44 +01:00
|
|
|
HKEY hShellExtKey;
|
2005-11-03 13:04:24 +01:00
|
|
|
WCHAR wszWineTestFolder[] = {
|
|
|
|
':',':','{','9','B','3','5','2','E','B','F','-','2','7','6','5','-','4','5','C','1','-',
|
|
|
|
'B','4','C','6','-','8','5','C','C','7','F','7','A','B','C','6','4','}',0 };
|
2005-12-20 11:57:44 +01:00
|
|
|
WCHAR wszShellExtKey[] = { 'S','o','f','t','w','a','r','e','\\',
|
|
|
|
'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\',
|
|
|
|
'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
|
|
|
|
'E','x','p','l','o','r','e','r','\\','D','e','s','k','t','o','p','\\',
|
|
|
|
'N','a','m','e','S','p','a','c','e','\\',
|
|
|
|
'{','9','b','3','5','2','e','b','f','-','2','7','6','5','-','4','5','c','1','-',
|
|
|
|
'b','4','c','6','-','8','5','c','c','7','f','7','a','b','c','6','4','}',0 };
|
|
|
|
|
2005-11-03 13:04:24 +01:00
|
|
|
WCHAR wszSomeSubFolder[] = { 'S','u','b','F','o','l','d','e','r', 0};
|
2005-11-05 11:44:28 +01:00
|
|
|
static const GUID CLSID_UnixDosFolder =
|
|
|
|
{0x9d20aae8, 0x0625, 0x44b0, {0x9c, 0xa7, 0x71, 0x88, 0x9c, 0x22, 0x54, 0xd9}};
|
|
|
|
|
2009-01-21 12:03:44 +01:00
|
|
|
if (!pSHGetSpecialFolderPathW || !pStrRetToBufW) {
|
|
|
|
win_skip("SHGetSpecialFolderPathW and/or StrRetToBufW are not available\n");
|
|
|
|
return;
|
|
|
|
}
|
2009-04-09 00:01:12 +02:00
|
|
|
|
|
|
|
if (!pSHGetFolderPathAndSubDirA)
|
|
|
|
{
|
|
|
|
win_skip("FolderShortcut test doesn't work on Win2k\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-08-23 11:37:59 +02:00
|
|
|
/* These tests basically show, that CLSID_FolderShortcuts are initialized
|
|
|
|
* via their IPersistPropertyBag interface. And that the target folder
|
|
|
|
* is taken from the IPropertyBag's 'Target' property.
|
|
|
|
*/
|
|
|
|
hr = CoCreateInstance(&CLSID_FolderShortcut, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IPersistPropertyBag, (LPVOID*)&pPersistPropertyBag);
|
2009-01-21 12:03:44 +01:00
|
|
|
if (hr == REGDB_E_CLASSNOTREG) {
|
|
|
|
win_skip("CLSID_FolderShortcut is not implemented\n");
|
|
|
|
return;
|
|
|
|
}
|
2010-03-23 02:21:13 +01:00
|
|
|
ok (hr == S_OK, "CoCreateInstance failed! hr = 0x%08x\n", hr);
|
|
|
|
if (hr != S_OK) return;
|
2005-08-23 11:37:59 +02:00
|
|
|
|
|
|
|
hr = IPersistPropertyBag_Load(pPersistPropertyBag, &InitPropertyBag, NULL);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(hr == S_OK, "IPersistPropertyBag_Load failed! hr = %08x\n", hr);
|
|
|
|
if (hr != S_OK) {
|
2005-08-23 11:37:59 +02:00
|
|
|
IPersistPropertyBag_Release(pPersistPropertyBag);
|
|
|
|
return;
|
|
|
|
}
|
2009-04-09 00:01:12 +02:00
|
|
|
|
2005-08-23 11:37:59 +02:00
|
|
|
hr = IPersistPropertyBag_QueryInterface(pPersistPropertyBag, &IID_IShellFolder,
|
|
|
|
(LPVOID*)&pShellFolder);
|
|
|
|
IPersistPropertyBag_Release(pPersistPropertyBag);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(hr == S_OK, "IPersistPropertyBag_QueryInterface(IShellFolder) failed! hr = %08x\n", hr);
|
|
|
|
if (hr != S_OK) return;
|
2005-08-23 11:37:59 +02:00
|
|
|
|
|
|
|
hr = IShellFolder_GetDisplayNameOf(pShellFolder, NULL, SHGDN_FORPARSING, &strret);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(hr == S_OK, "IShellFolder_GetDisplayNameOf(NULL) failed! hr = %08x\n", hr);
|
|
|
|
if (hr != S_OK) {
|
2005-08-23 11:37:59 +02:00
|
|
|
IShellFolder_Release(pShellFolder);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-11-03 13:04:24 +01:00
|
|
|
result = pSHGetSpecialFolderPathW(NULL, wszDesktopPath, CSIDL_DESKTOPDIRECTORY, FALSE);
|
2007-01-05 21:48:19 +01:00
|
|
|
ok(result, "SHGetSpecialFolderPathW(CSIDL_DESKTOPDIRECTORY) failed! %u\n", GetLastError());
|
2005-08-23 11:37:59 +02:00
|
|
|
if (!result) return;
|
|
|
|
|
|
|
|
pStrRetToBufW(&strret, NULL, wszBuffer, MAX_PATH);
|
2005-11-03 13:04:24 +01:00
|
|
|
ok(!lstrcmpiW(wszDesktopPath, wszBuffer), "FolderShortcut returned incorrect folder!\n");
|
2005-08-23 11:37:59 +02:00
|
|
|
|
|
|
|
hr = IShellFolder_QueryInterface(pShellFolder, &IID_IPersistFolder3, (LPVOID*)&pPersistFolder3);
|
|
|
|
IShellFolder_Release(pShellFolder);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(hr == S_OK, "IShellFolder_QueryInterface(IID_IPersistFolder3 failed! hr = 0x%08x\n", hr);
|
|
|
|
if (hr != S_OK) return;
|
2005-08-23 11:37:59 +02:00
|
|
|
|
|
|
|
hr = IPersistFolder3_GetClassID(pPersistFolder3, &clsid);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(hr == S_OK, "IPersistFolder3_GetClassID failed! hr=0x%08x\n", hr);
|
2005-08-23 11:37:59 +02:00
|
|
|
ok(IsEqualCLSID(&clsid, &CLSID_FolderShortcut), "Unexpected CLSID!\n");
|
|
|
|
|
|
|
|
hr = IPersistFolder3_GetCurFolder(pPersistFolder3, &pidlCurrentFolder);
|
2010-03-23 02:21:13 +01:00
|
|
|
todo_wine ok(hr == S_FALSE, "IPersistFolder3_GetCurFolder failed! hr=0x%08x\n", hr);
|
2005-08-23 11:37:59 +02:00
|
|
|
ok(!pidlCurrentFolder, "IPersistFolder3_GetCurFolder should return a NULL pidl!\n");
|
|
|
|
|
2005-11-03 13:04:24 +01:00
|
|
|
/* For FolderShortcut objects, the Initialize method initialized the folder's position in the
|
|
|
|
* shell namespace. The target folder, read from the property bag above, remains untouched.
|
|
|
|
* The following tests show this: The itemidlist for some imaginary shellfolder object
|
|
|
|
* is created and the FolderShortcut is initialized with it. GetCurFolder now returns this
|
|
|
|
* itemidlist, but GetDisplayNameOf still returns the path from above.
|
|
|
|
*/
|
|
|
|
hr = SHGetDesktopFolder(&pDesktopFolder);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok (hr == S_OK, "SHGetDesktopFolder failed! hr = %08x\n", hr);
|
|
|
|
if (hr != S_OK) return;
|
2005-11-03 13:04:24 +01:00
|
|
|
|
2005-12-20 11:57:44 +01:00
|
|
|
/* Temporarily register WineTestFolder as a shell namespace extension at the Desktop.
|
|
|
|
* Otherwise ParseDisplayName fails on WinXP with E_INVALIDARG */
|
|
|
|
RegCreateKeyW(HKEY_CURRENT_USER, wszShellExtKey, &hShellExtKey);
|
|
|
|
RegCloseKey(hShellExtKey);
|
2005-11-03 13:04:24 +01:00
|
|
|
hr = IShellFolder_ParseDisplayName(pDesktopFolder, NULL, NULL, wszWineTestFolder, NULL,
|
|
|
|
&pidlWineTestFolder, NULL);
|
2005-12-20 11:57:44 +01:00
|
|
|
RegDeleteKeyW(HKEY_CURRENT_USER, wszShellExtKey);
|
2005-11-03 13:04:24 +01:00
|
|
|
IShellFolder_Release(pDesktopFolder);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok (hr == S_OK, "IShellFolder::ParseDisplayName failed! hr = %08x\n", hr);
|
|
|
|
if (hr != S_OK) return;
|
2005-11-03 13:04:24 +01:00
|
|
|
|
|
|
|
hr = IPersistFolder3_Initialize(pPersistFolder3, pidlWineTestFolder);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok (hr == S_OK, "IPersistFolder3::Initialize failed! hr = %08x\n", hr);
|
|
|
|
if (hr != S_OK) {
|
2005-11-03 13:04:24 +01:00
|
|
|
IPersistFolder3_Release(pPersistFolder3);
|
2007-02-09 12:38:11 +01:00
|
|
|
pILFree(pidlWineTestFolder);
|
2005-11-03 13:04:24 +01:00
|
|
|
return;
|
|
|
|
}
|
2007-02-09 12:38:11 +01:00
|
|
|
|
2005-11-03 13:04:24 +01:00
|
|
|
hr = IPersistFolder3_GetCurFolder(pPersistFolder3, &pidlCurrentFolder);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(hr == S_OK, "IPersistFolder3_GetCurFolder failed! hr=0x%08x\n", hr);
|
2007-02-09 12:38:11 +01:00
|
|
|
ok(pILIsEqual(pidlCurrentFolder, pidlWineTestFolder),
|
2005-11-03 13:04:24 +01:00
|
|
|
"IPersistFolder3_GetCurFolder should return pidlWineTestFolder!\n");
|
2007-02-09 12:38:11 +01:00
|
|
|
pILFree(pidlCurrentFolder);
|
|
|
|
pILFree(pidlWineTestFolder);
|
|
|
|
|
2005-11-03 13:04:24 +01:00
|
|
|
hr = IPersistFolder3_QueryInterface(pPersistFolder3, &IID_IShellFolder, (LPVOID*)&pShellFolder);
|
|
|
|
IPersistFolder3_Release(pPersistFolder3);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(hr == S_OK, "IPersistFolder3_QueryInterface(IShellFolder) failed! hr = %08x\n", hr);
|
|
|
|
if (hr != S_OK) return;
|
2005-11-03 13:04:24 +01:00
|
|
|
|
|
|
|
hr = IShellFolder_GetDisplayNameOf(pShellFolder, NULL, SHGDN_FORPARSING, &strret);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(hr == S_OK, "IShellFolder_GetDisplayNameOf(NULL) failed! hr = %08x\n", hr);
|
|
|
|
if (hr != S_OK) {
|
2005-11-03 13:04:24 +01:00
|
|
|
IShellFolder_Release(pShellFolder);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
pStrRetToBufW(&strret, NULL, wszBuffer, MAX_PATH);
|
|
|
|
ok(!lstrcmpiW(wszDesktopPath, wszBuffer), "FolderShortcut returned incorrect folder!\n");
|
|
|
|
|
|
|
|
/* Next few lines are meant to show that children of FolderShortcuts are not FolderShortcuts,
|
|
|
|
* but ShellFSFolders. */
|
2007-12-18 10:00:47 +01:00
|
|
|
myPathAddBackslashW(wszDesktopPath);
|
2005-11-03 13:04:24 +01:00
|
|
|
lstrcatW(wszDesktopPath, wszSomeSubFolder);
|
|
|
|
if (!CreateDirectoryW(wszDesktopPath, NULL)) {
|
|
|
|
IShellFolder_Release(pShellFolder);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IShellFolder_ParseDisplayName(pShellFolder, NULL, NULL, wszSomeSubFolder, NULL,
|
|
|
|
&pidlSubFolder, NULL);
|
2005-11-05 11:44:28 +01:00
|
|
|
RemoveDirectoryW(wszDesktopPath);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok (hr == S_OK, "IShellFolder::ParseDisplayName failed! hr = %08x\n", hr);
|
|
|
|
if (hr != S_OK) {
|
2005-11-03 13:04:24 +01:00
|
|
|
IShellFolder_Release(pShellFolder);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-02-09 12:38:11 +01:00
|
|
|
hr = IShellFolder_BindToObject(pShellFolder, pidlSubFolder, NULL, &IID_IPersistFolder3,
|
2005-11-03 13:04:24 +01:00
|
|
|
(LPVOID*)&pPersistFolder3);
|
|
|
|
IShellFolder_Release(pShellFolder);
|
2007-02-09 12:38:11 +01:00
|
|
|
pILFree(pidlSubFolder);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok (hr == S_OK, "IShellFolder::BindToObject failed! hr = %08x\n", hr);
|
|
|
|
if (hr != S_OK)
|
2005-11-03 13:04:24 +01:00
|
|
|
return;
|
|
|
|
|
2005-11-05 11:44:28 +01:00
|
|
|
/* On windows, we expect CLSID_ShellFSFolder. On wine we relax this constraint
|
|
|
|
* a little bit and also allow CLSID_UnixDosFolder. */
|
2005-11-03 13:04:24 +01:00
|
|
|
hr = IPersistFolder3_GetClassID(pPersistFolder3, &clsid);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(hr == S_OK, "IPersistFolder3_GetClassID failed! hr=0x%08x\n", hr);
|
2005-11-05 11:44:28 +01:00
|
|
|
ok(IsEqualCLSID(&clsid, &CLSID_ShellFSFolder) || IsEqualCLSID(&clsid, &CLSID_UnixDosFolder),
|
|
|
|
"IPersistFolder3::GetClassID returned unexpected CLSID!\n");
|
2005-11-03 13:04:24 +01:00
|
|
|
|
2005-08-23 11:37:59 +02:00
|
|
|
IPersistFolder3_Release(pPersistFolder3);
|
|
|
|
}
|
|
|
|
|
2005-12-22 17:16:11 +01:00
|
|
|
#include "pshpack1.h"
|
|
|
|
struct FileStructA {
|
|
|
|
BYTE type;
|
|
|
|
BYTE dummy;
|
|
|
|
DWORD dwFileSize;
|
|
|
|
WORD uFileDate; /* In our current implementation this is */
|
|
|
|
WORD uFileTime; /* FileTimeToDosDate(WIN32_FIND_DATA->ftLastWriteTime) */
|
|
|
|
WORD uFileAttribs;
|
|
|
|
CHAR szName[1];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct FileStructW {
|
|
|
|
WORD cbLen; /* Length of this element. */
|
|
|
|
BYTE abFooBar1[6]; /* Beyond any recognition. */
|
|
|
|
WORD uDate; /* FileTimeToDosDate(WIN32_FIND_DATA->ftCreationTime)? */
|
|
|
|
WORD uTime; /* (this is currently speculation) */
|
|
|
|
WORD uDate2; /* FileTimeToDosDate(WIN32_FIND_DATA->ftLastAccessTime)? */
|
|
|
|
WORD uTime2; /* (this is currently speculation) */
|
|
|
|
BYTE abFooBar2[4]; /* Beyond any recognition. */
|
|
|
|
WCHAR wszName[1]; /* The long filename in unicode. */
|
|
|
|
/* Just for documentation: Right after the unicode string: */
|
|
|
|
WORD cbOffset; /* FileStructW's offset from the beginning of the SHITMEID.
|
|
|
|
* SHITEMID->cb == uOffset + cbLen */
|
|
|
|
};
|
|
|
|
#include "poppack.h"
|
|
|
|
|
2006-12-10 16:51:26 +01:00
|
|
|
static void test_ITEMIDLIST_format(void) {
|
2005-12-22 17:16:11 +01:00
|
|
|
WCHAR wszPersonal[MAX_PATH];
|
|
|
|
LPSHELLFOLDER psfDesktop, psfPersonal;
|
|
|
|
LPITEMIDLIST pidlPersonal, pidlFile;
|
|
|
|
HANDLE hFile;
|
|
|
|
HRESULT hr;
|
|
|
|
BOOL bResult;
|
2009-04-09 01:30:31 +02:00
|
|
|
WCHAR wszFile[3][17] = { { 'e','v','e','n','_',0 }, { 'o','d','d','_',0 },
|
2005-12-22 17:16:11 +01:00
|
|
|
{ 'l','o','n','g','e','r','_','t','h','a','n','.','8','_','3',0 } };
|
|
|
|
int i;
|
2009-04-09 01:30:31 +02:00
|
|
|
|
|
|
|
if (!pSHGetSpecialFolderPathW) return;
|
2005-12-22 17:16:11 +01:00
|
|
|
|
|
|
|
bResult = pSHGetSpecialFolderPathW(NULL, wszPersonal, CSIDL_PERSONAL, FALSE);
|
2007-01-05 21:48:19 +01:00
|
|
|
ok(bResult, "SHGetSpecialFolderPathW failed! Last error: %u\n", GetLastError());
|
2005-12-22 17:16:11 +01:00
|
|
|
if (!bResult) return;
|
|
|
|
|
2008-09-01 16:03:44 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
2005-12-22 17:16:11 +01:00
|
|
|
bResult = SetCurrentDirectoryW(wszPersonal);
|
2008-09-01 16:03:44 +02:00
|
|
|
if (!bResult && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) {
|
|
|
|
win_skip("Most W-calls are not implemented\n");
|
|
|
|
return;
|
|
|
|
}
|
2007-01-05 21:48:19 +01:00
|
|
|
ok(bResult, "SetCurrentDirectory failed! Last error: %u\n", GetLastError());
|
2005-12-22 17:16:11 +01:00
|
|
|
if (!bResult) return;
|
|
|
|
|
|
|
|
hr = SHGetDesktopFolder(&psfDesktop);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(hr == S_OK, "SHGetDesktopFolder failed! hr: %08x\n", hr);
|
|
|
|
if (hr != S_OK) return;
|
2005-12-22 17:16:11 +01:00
|
|
|
|
|
|
|
hr = IShellFolder_ParseDisplayName(psfDesktop, NULL, NULL, wszPersonal, NULL, &pidlPersonal, NULL);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(hr == S_OK, "psfDesktop->ParseDisplayName failed! hr = %08x\n", hr);
|
|
|
|
if (hr != S_OK) {
|
2005-12-22 17:16:11 +01:00
|
|
|
IShellFolder_Release(psfDesktop);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-02-09 12:38:11 +01:00
|
|
|
hr = IShellFolder_BindToObject(psfDesktop, pidlPersonal, NULL, &IID_IShellFolder,
|
2005-12-22 17:16:11 +01:00
|
|
|
(LPVOID*)&psfPersonal);
|
|
|
|
IShellFolder_Release(psfDesktop);
|
2007-02-09 12:38:11 +01:00
|
|
|
pILFree(pidlPersonal);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(hr == S_OK, "psfDesktop->BindToObject failed! hr = %08x\n", hr);
|
|
|
|
if (hr != S_OK) return;
|
2005-12-22 17:16:11 +01:00
|
|
|
|
|
|
|
for (i=0; i<3; i++) {
|
|
|
|
CHAR szFile[MAX_PATH];
|
|
|
|
struct FileStructA *pFileStructA;
|
|
|
|
WORD cbOffset;
|
2009-04-09 01:30:31 +02:00
|
|
|
|
2005-12-22 17:16:11 +01:00
|
|
|
WideCharToMultiByte(CP_ACP, 0, wszFile[i], -1, szFile, MAX_PATH, NULL, NULL);
|
2009-04-09 01:30:31 +02:00
|
|
|
|
2005-12-22 17:16:11 +01:00
|
|
|
hFile = CreateFileW(wszFile[i], GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_FLAG_WRITE_THROUGH, NULL);
|
2007-01-05 21:48:19 +01:00
|
|
|
ok(hFile != INVALID_HANDLE_VALUE, "CreateFile failed! (%u)\n", GetLastError());
|
2005-12-22 17:16:11 +01:00
|
|
|
if (hFile == INVALID_HANDLE_VALUE) {
|
|
|
|
IShellFolder_Release(psfPersonal);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
CloseHandle(hFile);
|
|
|
|
|
|
|
|
hr = IShellFolder_ParseDisplayName(psfPersonal, NULL, NULL, wszFile[i], NULL, &pidlFile, NULL);
|
|
|
|
DeleteFileW(wszFile[i]);
|
2010-03-23 02:21:13 +01:00
|
|
|
ok(hr == S_OK, "psfPersonal->ParseDisplayName failed! hr: %08x\n", hr);
|
|
|
|
if (hr != S_OK) {
|
2005-12-22 17:16:11 +01:00
|
|
|
IShellFolder_Release(psfPersonal);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
pFileStructA = (struct FileStructA *)pidlFile->mkid.abID;
|
|
|
|
ok(pFileStructA->type == 0x32, "PIDLTYPE should be 0x32!\n");
|
|
|
|
ok(pFileStructA->dummy == 0x00, "Dummy Byte should be 0x00!\n");
|
2009-04-09 01:30:31 +02:00
|
|
|
ok(pFileStructA->dwFileSize == 0, "Filesize should be zero!\n");
|
2005-12-22 17:16:11 +01:00
|
|
|
|
2009-04-09 01:30:31 +02:00
|
|
|
if (i < 2) /* First two file names are already in valid 8.3 format */
|
2005-12-22 17:16:11 +01:00
|
|
|
ok(!strcmp(szFile, (CHAR*)&pidlFile->mkid.abID[12]), "Wrong file name!\n");
|
2009-04-09 01:30:31 +02:00
|
|
|
else
|
2005-12-22 17:16:11 +01:00
|
|
|
/* WinXP stores a derived 8.3 dos name (LONGER~1.8_3) here. We probably
|
|
|
|
* can't implement this correctly, since unix filesystems don't support
|
|
|
|
* this nasty short/long filename stuff. So we'll probably stay with our
|
2011-08-03 23:50:18 +02:00
|
|
|
* current habit of storing the long filename here, which seems to work
|
2005-12-22 17:16:11 +01:00
|
|
|
* just fine. */
|
2009-04-09 01:30:31 +02:00
|
|
|
todo_wine
|
|
|
|
ok(pidlFile->mkid.abID[18] == '~' ||
|
|
|
|
broken(pidlFile->mkid.abID[34] == '~'), /* Win2k */
|
|
|
|
"Should be derived 8.3 name!\n");
|
2005-12-22 17:16:11 +01:00
|
|
|
|
|
|
|
if (i == 0) /* First file name has an even number of chars. No need for alignment. */
|
2009-04-09 01:30:31 +02:00
|
|
|
ok(pidlFile->mkid.abID[12 + strlen(szFile) + 1] != '\0' ||
|
|
|
|
broken(pidlFile->mkid.cb == 2 + 12 + strlen(szFile) + 1 + 1), /* Win2k */
|
|
|
|
"Alignment byte, where there shouldn't be!\n");
|
|
|
|
|
2005-12-22 17:16:11 +01:00
|
|
|
if (i == 1) /* Second file name has an uneven number of chars => alignment byte */
|
2009-04-09 01:30:31 +02:00
|
|
|
ok(pidlFile->mkid.abID[12 + strlen(szFile) + 1] == '\0',
|
2005-12-22 17:16:11 +01:00
|
|
|
"There should be an alignment byte, but isn't!\n");
|
|
|
|
|
|
|
|
/* The offset of the FileStructW member is stored as a WORD at the end of the pidl. */
|
|
|
|
cbOffset = *(WORD*)(((LPBYTE)pidlFile)+pidlFile->mkid.cb-sizeof(WORD));
|
2009-04-09 01:30:31 +02:00
|
|
|
ok ((cbOffset >= sizeof(struct FileStructA) &&
|
|
|
|
cbOffset <= pidlFile->mkid.cb - sizeof(struct FileStructW)) ||
|
|
|
|
broken(pidlFile->mkid.cb == 2 + 12 + strlen(szFile) + 1 + 1) || /* Win2k on short names */
|
|
|
|
broken(pidlFile->mkid.cb == 2 + 12 + strlen(szFile) + 1 + 12 + 1), /* Win2k on long names */
|
2006-01-03 13:23:59 +01:00
|
|
|
"Wrong offset value (%d) stored at the end of the PIDL\n", cbOffset);
|
2005-12-22 17:16:11 +01:00
|
|
|
|
|
|
|
if (cbOffset >= sizeof(struct FileStructA) &&
|
2009-04-09 01:30:31 +02:00
|
|
|
cbOffset <= pidlFile->mkid.cb - sizeof(struct FileStructW))
|
2005-12-22 17:16:11 +01:00
|
|
|
{
|
|
|
|
struct FileStructW *pFileStructW = (struct FileStructW *)(((LPBYTE)pidlFile)+cbOffset);
|
2011-11-07 11:44:35 +01:00
|
|
|
WCHAR *name = pFileStructW->wszName;
|
2005-12-22 17:16:11 +01:00
|
|
|
|
2009-04-09 01:30:31 +02:00
|
|
|
ok(pidlFile->mkid.cb == cbOffset + pFileStructW->cbLen,
|
2005-12-22 17:16:11 +01:00
|
|
|
"FileStructW's offset and length should add up to the PIDL's length!\n");
|
|
|
|
|
|
|
|
if (pidlFile->mkid.cb == cbOffset + pFileStructW->cbLen) {
|
|
|
|
/* Since we just created the file, time of creation,
|
2009-04-09 01:30:31 +02:00
|
|
|
* time of last access and time of last write access just be the same.
|
|
|
|
* These tests seem to fail sometimes (on WinXP), if the test is run again shortly
|
2005-12-22 17:16:11 +01:00
|
|
|
* after the first run. I do remember something with NTFS keeping the creation time
|
|
|
|
* if a file is deleted and then created again within a couple of seconds or so.
|
|
|
|
* Might be the reason. */
|
|
|
|
ok (pFileStructA->uFileDate == pFileStructW->uDate &&
|
|
|
|
pFileStructA->uFileTime == pFileStructW->uTime,
|
|
|
|
"Last write time should match creation time!\n");
|
2009-04-09 01:30:31 +02:00
|
|
|
|
2009-11-21 00:02:32 +01:00
|
|
|
/* On FAT filesystems the last access time is midnight
|
|
|
|
local time, so the values of uDate2 and uTime2 will
|
|
|
|
depend on the local timezone. If the times are exactly
|
|
|
|
equal then the dates should be identical for both FAT
|
|
|
|
and NTFS as no timezone is more than 1 day away from UTC.
|
|
|
|
*/
|
|
|
|
if (pFileStructA->uFileTime == pFileStructW->uTime2)
|
|
|
|
{
|
|
|
|
ok (pFileStructA->uFileDate == pFileStructW->uDate2,
|
|
|
|
"Last write date and time should match last access date and time!\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Filesystem may be FAT. Check date within 1 day
|
|
|
|
and seconds are zero. */
|
|
|
|
trace ("Filesystem may be FAT. Performing less strict atime test.\n");
|
|
|
|
ok ((pFileStructW->uTime2 & 0x1F) == 0,
|
|
|
|
"Last access time on FAT filesystems should have zero seconds.\n");
|
|
|
|
/* TODO: Perform check for date being within one day.*/
|
|
|
|
}
|
2005-12-22 17:16:11 +01:00
|
|
|
|
2011-11-07 11:44:35 +01:00
|
|
|
ok (!lstrcmpW(wszFile[i], name) ||
|
|
|
|
!lstrcmpW(wszFile[i], name + 9) || /* Vista */
|
|
|
|
!lstrcmpW(wszFile[i], name + 11), /* Win7 */
|
2005-12-22 17:16:11 +01:00
|
|
|
"The filename should be stored in unicode at this position!\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-02-09 12:38:11 +01:00
|
|
|
pILFree(pidlFile);
|
2005-12-22 17:16:11 +01:00
|
|
|
}
|
2009-12-14 02:16:13 +01:00
|
|
|
|
|
|
|
IShellFolder_Release(psfPersonal);
|
2005-12-22 17:16:11 +01:00
|
|
|
}
|
|
|
|
|
2010-09-21 13:36:17 +02:00
|
|
|
static void test_SHGetFolderPathA(void)
|
|
|
|
{
|
|
|
|
static const BOOL is_win64 = sizeof(void *) > sizeof(int);
|
|
|
|
BOOL is_wow64;
|
|
|
|
char path[MAX_PATH];
|
|
|
|
char path_x86[MAX_PATH];
|
|
|
|
char path_key[MAX_PATH];
|
|
|
|
HRESULT hr;
|
|
|
|
HKEY key;
|
|
|
|
|
|
|
|
if (!pSHGetFolderPathA)
|
|
|
|
{
|
|
|
|
win_skip("SHGetFolderPathA not present\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!pIsWow64Process || !pIsWow64Process( GetCurrentProcess(), &is_wow64 )) is_wow64 = FALSE;
|
|
|
|
|
|
|
|
hr = pSHGetFolderPathA( 0, CSIDL_PROGRAM_FILES, 0, SHGFP_TYPE_CURRENT, path );
|
|
|
|
ok( !hr, "SHGetFolderPathA failed %x\n", hr );
|
|
|
|
hr = pSHGetFolderPathA( 0, CSIDL_PROGRAM_FILESX86, 0, SHGFP_TYPE_CURRENT, path_x86 );
|
|
|
|
if (hr == E_FAIL)
|
|
|
|
{
|
|
|
|
win_skip( "Program Files (x86) not supported\n" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ok( !hr, "SHGetFolderPathA failed %x\n", hr );
|
|
|
|
if (is_win64)
|
|
|
|
{
|
|
|
|
ok( lstrcmpiA( path, path_x86 ), "paths are identical '%s'\n", path );
|
|
|
|
ok( strstr( path, "x86" ) == NULL, "64-bit path '%s' contains x86\n", path );
|
|
|
|
ok( strstr( path_x86, "x86" ) != NULL, "32-bit path '%s' doesn't contain x86\n", path_x86 );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ok( !lstrcmpiA( path, path_x86 ), "paths differ '%s' != '%s'\n", path, path_x86 );
|
|
|
|
if (is_wow64)
|
|
|
|
ok( strstr( path, "x86" ) != NULL, "32-bit path '%s' doesn't contain x86\n", path );
|
|
|
|
else
|
|
|
|
ok( strstr( path, "x86" ) == NULL, "32-bit path '%s' contains x86\n", path );
|
|
|
|
}
|
|
|
|
if (!RegOpenKeyA( HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion", &key ))
|
|
|
|
{
|
|
|
|
DWORD type, count = sizeof(path_x86);
|
|
|
|
if (!RegQueryValueExA( key, "ProgramFilesDir (x86)", NULL, &type, (BYTE *)path_key, &count ))
|
|
|
|
{
|
|
|
|
ok( is_win64 || is_wow64, "ProgramFilesDir (x86) exists on 32-bit setup\n" );
|
|
|
|
ok( !lstrcmpiA( path_key, path_x86 ), "paths differ '%s' != '%s'\n", path_key, path_x86 );
|
|
|
|
}
|
|
|
|
else ok( !is_win64 && !is_wow64, "ProgramFilesDir (x86) should exist on 64-bit setup\n" );
|
|
|
|
RegCloseKey( key );
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = pSHGetFolderPathA( 0, CSIDL_PROGRAM_FILES_COMMON, 0, SHGFP_TYPE_CURRENT, path );
|
|
|
|
ok( !hr, "SHGetFolderPathA failed %x\n", hr );
|
|
|
|
hr = pSHGetFolderPathA( 0, CSIDL_PROGRAM_FILES_COMMONX86, 0, SHGFP_TYPE_CURRENT, path_x86 );
|
|
|
|
if (hr == E_FAIL)
|
|
|
|
{
|
|
|
|
win_skip( "Common Files (x86) not supported\n" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ok( !hr, "SHGetFolderPathA failed %x\n", hr );
|
|
|
|
if (is_win64)
|
|
|
|
{
|
|
|
|
ok( lstrcmpiA( path, path_x86 ), "paths are identical '%s'\n", path );
|
|
|
|
ok( strstr( path, "x86" ) == NULL, "64-bit path '%s' contains x86\n", path );
|
|
|
|
ok( strstr( path_x86, "x86" ) != NULL, "32-bit path '%s' doesn't contain x86\n", path_x86 );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ok( !lstrcmpiA( path, path_x86 ), "paths differ '%s' != '%s'\n", path, path_x86 );
|
|
|
|
if (is_wow64)
|
|
|
|
ok( strstr( path, "x86" ) != NULL, "32-bit path '%s' doesn't contain x86\n", path );
|
|
|
|
else
|
|
|
|
ok( strstr( path, "x86" ) == NULL, "32-bit path '%s' contains x86\n", path );
|
|
|
|
}
|
|
|
|
if (!RegOpenKeyA( HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion", &key ))
|
|
|
|
{
|
|
|
|
DWORD type, count = sizeof(path_x86);
|
|
|
|
if (!RegQueryValueExA( key, "CommonFilesDir (x86)", NULL, &type, (BYTE *)path_key, &count ))
|
|
|
|
{
|
|
|
|
ok( is_win64 || is_wow64, "CommonFilesDir (x86) exists on 32-bit setup\n" );
|
|
|
|
ok( !lstrcmpiA( path_key, path_x86 ), "paths differ '%s' != '%s'\n", path_key, path_x86 );
|
|
|
|
}
|
|
|
|
else ok( !is_win64 && !is_wow64, "CommonFilesDir (x86) should exist on 64-bit setup\n" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-02 22:00:52 +01:00
|
|
|
static void test_SHGetFolderPathAndSubDirA(void)
|
2008-03-03 23:44:52 +01:00
|
|
|
{
|
|
|
|
HRESULT ret;
|
|
|
|
BOOL delret;
|
|
|
|
DWORD dwret;
|
|
|
|
int i;
|
|
|
|
static char wine[] = "wine";
|
|
|
|
static char winetemp[] = "wine\\temp";
|
|
|
|
static char appdata[MAX_PATH];
|
|
|
|
static char testpath[MAX_PATH];
|
|
|
|
static char toolongpath[MAX_PATH+1];
|
|
|
|
|
2010-03-02 22:00:52 +01:00
|
|
|
if(!pSHGetFolderPathAndSubDirA)
|
|
|
|
{
|
|
|
|
win_skip("SHGetFolderPathAndSubDirA not present!\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-03-03 23:44:52 +01:00
|
|
|
if(!pSHGetFolderPathA) {
|
2009-06-18 18:02:20 +02:00
|
|
|
win_skip("SHGetFolderPathA not present!\n");
|
2008-03-03 23:44:52 +01:00
|
|
|
return;
|
|
|
|
}
|
2008-10-08 01:32:27 +02:00
|
|
|
if(FAILED(pSHGetFolderPathA(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, appdata)))
|
2008-03-03 23:44:52 +01:00
|
|
|
{
|
2009-06-20 12:51:06 +02:00
|
|
|
win_skip("SHGetFolderPathA failed for CSIDL_LOCAL_APPDATA!\n");
|
2008-03-03 23:44:52 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(testpath, "%s\\%s", appdata, winetemp);
|
|
|
|
delret = RemoveDirectoryA(testpath);
|
|
|
|
if(!delret && (ERROR_PATH_NOT_FOUND != GetLastError()) ) {
|
2009-06-20 12:51:06 +02:00
|
|
|
win_skip("RemoveDirectoryA(%s) failed with error %u\n", testpath, GetLastError());
|
2008-03-03 23:44:52 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(testpath, "%s\\%s", appdata, wine);
|
|
|
|
delret = RemoveDirectoryA(testpath);
|
|
|
|
if(!delret && (ERROR_PATH_NOT_FOUND != GetLastError()) && (ERROR_FILE_NOT_FOUND != GetLastError())) {
|
2009-06-20 12:51:06 +02:00
|
|
|
win_skip("RemoveDirectoryA(%s) failed with error %u\n", testpath, GetLastError());
|
2008-03-03 23:44:52 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* test invalid second parameter */
|
|
|
|
ret = pSHGetFolderPathAndSubDirA(NULL, CSIDL_FLAG_DONT_VERIFY | 0xff, NULL, SHGFP_TYPE_CURRENT, wine, testpath);
|
|
|
|
ok(E_INVALIDARG == ret, "expected E_INVALIDARG, got %x\n", ret);
|
|
|
|
|
2009-06-18 18:02:20 +02:00
|
|
|
/* test fourth parameter */
|
|
|
|
ret = pSHGetFolderPathAndSubDirA(NULL, CSIDL_FLAG_DONT_VERIFY | CSIDL_LOCAL_APPDATA, NULL, 2, winetemp, testpath);
|
2008-03-13 23:23:44 +01:00
|
|
|
switch(ret) {
|
|
|
|
case S_OK: /* winvista */
|
|
|
|
ok(!strncmp(appdata, testpath, strlen(appdata)),
|
|
|
|
"expected %s to start with %s\n", testpath, appdata);
|
|
|
|
ok(!lstrcmpA(&testpath[1 + strlen(appdata)], winetemp),
|
|
|
|
"expected %s to end with %s\n", testpath, winetemp);
|
|
|
|
break;
|
|
|
|
case E_INVALIDARG: /* winxp, win2k3 */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ok(0, "expected S_OK or E_INVALIDARG, got %x\n", ret);
|
|
|
|
}
|
2008-03-03 23:44:52 +01:00
|
|
|
|
|
|
|
/* test fifth parameter */
|
|
|
|
testpath[0] = '\0';
|
|
|
|
ret = pSHGetFolderPathAndSubDirA(NULL, CSIDL_FLAG_DONT_VERIFY | CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, NULL, testpath);
|
|
|
|
ok(S_OK == ret, "expected S_OK, got %x\n", ret);
|
|
|
|
ok(!lstrcmpA(appdata, testpath), "expected %s, got %s\n", appdata, testpath);
|
|
|
|
|
|
|
|
testpath[0] = '\0';
|
|
|
|
ret = pSHGetFolderPathAndSubDirA(NULL, CSIDL_FLAG_DONT_VERIFY | CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, "", testpath);
|
|
|
|
ok(S_OK == ret, "expected S_OK, got %x\n", ret);
|
|
|
|
ok(!lstrcmpA(appdata, testpath), "expected %s, got %s\n", appdata, testpath);
|
|
|
|
|
|
|
|
testpath[0] = '\0';
|
|
|
|
ret = pSHGetFolderPathAndSubDirA(NULL, CSIDL_FLAG_DONT_VERIFY | CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, "\\", testpath);
|
|
|
|
ok(S_OK == ret, "expected S_OK, got %x\n", ret);
|
|
|
|
ok(!lstrcmpA(appdata, testpath), "expected %s, got %s\n", appdata, testpath);
|
|
|
|
|
2009-06-18 18:02:20 +02:00
|
|
|
for(i=0; i< MAX_PATH; i++)
|
|
|
|
toolongpath[i] = '0' + i % 10;
|
|
|
|
toolongpath[MAX_PATH] = '\0';
|
2008-03-03 23:44:52 +01:00
|
|
|
ret = pSHGetFolderPathAndSubDirA(NULL, CSIDL_FLAG_DONT_VERIFY | CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, toolongpath, testpath);
|
|
|
|
ok(HRESULT_FROM_WIN32(ERROR_FILENAME_EXCED_RANGE) == ret,
|
|
|
|
"expected %x, got %x\n", HRESULT_FROM_WIN32(ERROR_FILENAME_EXCED_RANGE), ret);
|
|
|
|
|
|
|
|
testpath[0] = '\0';
|
|
|
|
ret = pSHGetFolderPathAndSubDirA(NULL, CSIDL_FLAG_DONT_VERIFY | CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, wine, NULL);
|
2008-03-13 23:23:44 +01:00
|
|
|
ok((S_OK == ret) || (E_INVALIDARG == ret), "expected S_OK or E_INVALIDARG, got %x\n", ret);
|
2008-03-03 23:44:52 +01:00
|
|
|
|
|
|
|
/* test a not existing path */
|
|
|
|
testpath[0] = '\0';
|
|
|
|
ret = pSHGetFolderPathAndSubDirA(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, winetemp, testpath);
|
|
|
|
ok(HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND) == ret,
|
|
|
|
"expected %x, got %x\n", HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), ret);
|
|
|
|
|
|
|
|
/* create a directory inside a not existing directory */
|
|
|
|
testpath[0] = '\0';
|
|
|
|
ret = pSHGetFolderPathAndSubDirA(NULL, CSIDL_FLAG_CREATE | CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, winetemp, testpath);
|
|
|
|
ok(S_OK == ret, "expected S_OK, got %x\n", ret);
|
|
|
|
ok(!strncmp(appdata, testpath, strlen(appdata)),
|
|
|
|
"expected %s to start with %s\n", testpath, appdata);
|
|
|
|
ok(!lstrcmpA(&testpath[1 + strlen(appdata)], winetemp),
|
|
|
|
"expected %s to end with %s\n", testpath, winetemp);
|
|
|
|
dwret = GetFileAttributes(testpath);
|
|
|
|
ok(FILE_ATTRIBUTE_DIRECTORY | dwret, "expected %x to contain FILE_ATTRIBUTE_DIRECTORY\n", dwret);
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
sprintf(testpath, "%s\\%s", appdata, winetemp);
|
|
|
|
RemoveDirectoryA(testpath);
|
|
|
|
sprintf(testpath, "%s\\%s", appdata, wine);
|
|
|
|
RemoveDirectoryA(testpath);
|
|
|
|
}
|
|
|
|
|
2008-12-02 23:12:08 +01:00
|
|
|
static void test_LocalizedNames(void)
|
|
|
|
{
|
|
|
|
static char cCurrDirA[MAX_PATH];
|
|
|
|
WCHAR cCurrDirW[MAX_PATH], tempbufW[25];
|
|
|
|
IShellFolder *IDesktopFolder, *testIShellFolder;
|
|
|
|
ITEMIDLIST *newPIDL;
|
|
|
|
int len;
|
|
|
|
HRESULT hr;
|
|
|
|
static char resourcefile[MAX_PATH];
|
|
|
|
DWORD res;
|
|
|
|
HANDLE file;
|
|
|
|
STRRET strret;
|
2010-12-30 20:18:16 +01:00
|
|
|
BOOL ret;
|
2008-12-02 23:12:08 +01:00
|
|
|
|
|
|
|
static const char desktopini_contents1[] =
|
|
|
|
"[.ShellClassInfo]\r\n"
|
|
|
|
"LocalizedResourceName=@";
|
|
|
|
static const char desktopini_contents2[] =
|
|
|
|
",-1\r\n";
|
|
|
|
static WCHAR foldernameW[] = {'t','e','s','t','f','o','l','d','e','r',0};
|
|
|
|
static const WCHAR folderdisplayW[] = {'F','o','l','d','e','r',' ','N','a','m','e',' ','R','e','s','o','u','r','c','e',0};
|
|
|
|
|
|
|
|
/* create folder with desktop.ini and localized name in GetModuleFileNameA(NULL) */
|
|
|
|
CreateDirectoryA(".\\testfolder", NULL);
|
|
|
|
|
|
|
|
SetFileAttributesA(".\\testfolder", GetFileAttributesA(".\\testfolder")|FILE_ATTRIBUTE_SYSTEM);
|
|
|
|
|
|
|
|
GetModuleFileNameA(NULL, resourcefile, MAX_PATH);
|
|
|
|
|
|
|
|
file = CreateFileA(".\\testfolder\\desktop.ini", GENERIC_WRITE, 0, NULL,
|
|
|
|
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
ok(file != INVALID_HANDLE_VALUE, "CreateFileA failed %i\n", GetLastError());
|
2010-12-30 20:18:16 +01:00
|
|
|
ret = WriteFile(file, desktopini_contents1, strlen(desktopini_contents1), &res, NULL) &&
|
|
|
|
WriteFile(file, resourcefile, strlen(resourcefile), &res, NULL) &&
|
|
|
|
WriteFile(file, desktopini_contents2, strlen(desktopini_contents2), &res, NULL);
|
|
|
|
ok(ret, "WriteFile failed %i\n", GetLastError());
|
2008-12-02 23:12:08 +01:00
|
|
|
CloseHandle(file);
|
|
|
|
|
|
|
|
/* get IShellFolder for parent */
|
|
|
|
GetCurrentDirectoryA(MAX_PATH, cCurrDirA);
|
|
|
|
len = lstrlenA(cCurrDirA);
|
|
|
|
|
|
|
|
if (len == 0) {
|
2009-06-20 12:51:06 +02:00
|
|
|
win_skip("GetCurrentDirectoryA returned empty string. Skipping test_LocalizedNames\n");
|
2008-12-02 23:12:08 +01:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
if(cCurrDirA[len-1] == '\\')
|
|
|
|
cCurrDirA[len-1] = 0;
|
|
|
|
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, cCurrDirA, -1, cCurrDirW, MAX_PATH);
|
|
|
|
|
|
|
|
hr = SHGetDesktopFolder(&IDesktopFolder);
|
|
|
|
ok(hr == S_OK, "SHGetDesktopfolder failed %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IShellFolder_ParseDisplayName(IDesktopFolder, NULL, NULL, cCurrDirW, NULL, &newPIDL, 0);
|
|
|
|
ok(hr == S_OK, "ParseDisplayName failed %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IShellFolder_BindToObject(IDesktopFolder, newPIDL, NULL, (REFIID)&IID_IShellFolder, (LPVOID *)&testIShellFolder);
|
|
|
|
ok(hr == S_OK, "BindToObject failed %08x\n", hr);
|
|
|
|
|
|
|
|
IMalloc_Free(ppM, newPIDL);
|
|
|
|
|
|
|
|
/* windows reads the display name from the resource */
|
|
|
|
hr = IShellFolder_ParseDisplayName(testIShellFolder, NULL, NULL, foldernameW, NULL, &newPIDL, 0);
|
|
|
|
ok(hr == S_OK, "ParseDisplayName failed %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IShellFolder_GetDisplayNameOf(testIShellFolder, newPIDL, SHGDN_INFOLDER, &strret);
|
2008-12-05 16:52:39 +01:00
|
|
|
ok(hr == S_OK, "GetDisplayNameOf failed %08x\n", hr);
|
2008-12-02 23:12:08 +01:00
|
|
|
|
2010-03-23 02:21:13 +01:00
|
|
|
if (hr == S_OK && pStrRetToBufW)
|
2008-12-02 23:12:08 +01:00
|
|
|
{
|
|
|
|
hr = pStrRetToBufW(&strret, newPIDL, tempbufW, sizeof(tempbufW)/sizeof(WCHAR));
|
2010-03-23 02:21:13 +01:00
|
|
|
ok (hr == S_OK, "StrRetToBufW failed! hr = %08x\n", hr);
|
2008-12-05 16:52:39 +01:00
|
|
|
todo_wine
|
|
|
|
ok (!lstrcmpiW(tempbufW, folderdisplayW) ||
|
|
|
|
broken(!lstrcmpiW(tempbufW, foldernameW)), /* W2K */
|
|
|
|
"GetDisplayNameOf returned %s\n", wine_dbgstr_w(tempbufW));
|
2008-12-02 23:12:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* editing name is also read from the resource */
|
|
|
|
hr = IShellFolder_GetDisplayNameOf(testIShellFolder, newPIDL, SHGDN_INFOLDER|SHGDN_FOREDITING, &strret);
|
2008-12-05 16:52:39 +01:00
|
|
|
ok(hr == S_OK, "GetDisplayNameOf failed %08x\n", hr);
|
2008-12-02 23:12:08 +01:00
|
|
|
|
2010-03-23 02:21:13 +01:00
|
|
|
if (hr == S_OK && pStrRetToBufW)
|
2008-12-02 23:12:08 +01:00
|
|
|
{
|
|
|
|
hr = pStrRetToBufW(&strret, newPIDL, tempbufW, sizeof(tempbufW)/sizeof(WCHAR));
|
2010-03-23 02:21:13 +01:00
|
|
|
ok (hr == S_OK, "StrRetToBufW failed! hr = %08x\n", hr);
|
2008-12-05 16:52:39 +01:00
|
|
|
todo_wine
|
|
|
|
ok (!lstrcmpiW(tempbufW, folderdisplayW) ||
|
|
|
|
broken(!lstrcmpiW(tempbufW, foldernameW)), /* W2K */
|
|
|
|
"GetDisplayNameOf returned %s\n", wine_dbgstr_w(tempbufW));
|
2008-12-02 23:12:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* parsing name is unchanged */
|
|
|
|
hr = IShellFolder_GetDisplayNameOf(testIShellFolder, newPIDL, SHGDN_INFOLDER|SHGDN_FORPARSING, &strret);
|
2008-12-05 16:52:39 +01:00
|
|
|
ok(hr == S_OK, "GetDisplayNameOf failed %08x\n", hr);
|
2008-12-02 23:12:08 +01:00
|
|
|
|
2010-03-23 02:21:13 +01:00
|
|
|
if (hr == S_OK && pStrRetToBufW)
|
2008-12-02 23:12:08 +01:00
|
|
|
{
|
|
|
|
hr = pStrRetToBufW(&strret, newPIDL, tempbufW, sizeof(tempbufW)/sizeof(WCHAR));
|
2010-03-23 02:21:13 +01:00
|
|
|
ok (hr == S_OK, "StrRetToBufW failed! hr = %08x\n", hr);
|
2008-12-02 23:12:08 +01:00
|
|
|
ok (!lstrcmpiW(tempbufW, foldernameW), "GetDisplayNameOf returned %s\n", wine_dbgstr_w(tempbufW));
|
|
|
|
}
|
|
|
|
|
|
|
|
IShellFolder_Release(IDesktopFolder);
|
|
|
|
IShellFolder_Release(testIShellFolder);
|
|
|
|
|
|
|
|
IMalloc_Free(ppM, newPIDL);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
DeleteFileA(".\\testfolder\\desktop.ini");
|
|
|
|
SetFileAttributesA(".\\testfolder", GetFileAttributesA(".\\testfolder")&~FILE_ATTRIBUTE_SYSTEM);
|
|
|
|
RemoveDirectoryA(".\\testfolder");
|
|
|
|
}
|
|
|
|
|
2009-05-21 18:19:21 +02:00
|
|
|
static void test_SHCreateShellItem(void)
|
|
|
|
{
|
2009-05-21 20:18:26 +02:00
|
|
|
IShellItem *shellitem, *shellitem2;
|
2009-05-21 18:19:21 +02:00
|
|
|
IPersistIDList *persistidl;
|
2010-08-24 10:56:20 +02:00
|
|
|
LPITEMIDLIST pidl_cwd=NULL, pidl_testfile, pidl_abstestfile, pidl_test, pidl_desktop;
|
2009-05-21 18:19:21 +02:00
|
|
|
HRESULT ret;
|
|
|
|
char curdirA[MAX_PATH];
|
|
|
|
WCHAR curdirW[MAX_PATH];
|
2010-07-22 20:17:03 +02:00
|
|
|
WCHAR fnbufW[MAX_PATH];
|
2009-05-21 18:19:21 +02:00
|
|
|
IShellFolder *desktopfolder=NULL, *currentfolder=NULL;
|
|
|
|
static WCHAR testfileW[] = {'t','e','s','t','f','i','l','e',0};
|
|
|
|
|
|
|
|
GetCurrentDirectoryA(MAX_PATH, curdirA);
|
|
|
|
|
2010-03-02 22:00:52 +01:00
|
|
|
if (!pSHCreateShellItem)
|
|
|
|
{
|
|
|
|
win_skip("SHCreateShellItem isn't available\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-05-21 18:19:21 +02:00
|
|
|
if (!lstrlenA(curdirA))
|
|
|
|
{
|
|
|
|
win_skip("GetCurrentDirectoryA returned empty string, skipping test_SHCreateShellItem\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-08-24 10:56:20 +02:00
|
|
|
if(pSHGetSpecialFolderLocation)
|
|
|
|
{
|
|
|
|
ret = pSHGetSpecialFolderLocation(NULL, CSIDL_DESKTOP, &pidl_desktop);
|
|
|
|
ok(ret == S_OK, "Got 0x%08x\n", ret);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
win_skip("pSHGetSpecialFolderLocation missing.\n");
|
|
|
|
pidl_desktop = NULL;
|
|
|
|
}
|
|
|
|
|
2009-05-21 18:19:21 +02:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, curdirA, -1, curdirW, MAX_PATH);
|
|
|
|
|
|
|
|
ret = SHGetDesktopFolder(&desktopfolder);
|
|
|
|
ok(SUCCEEDED(ret), "SHGetShellFolder returned %x\n", ret);
|
|
|
|
|
|
|
|
ret = IShellFolder_ParseDisplayName(desktopfolder, NULL, NULL, curdirW, NULL, &pidl_cwd, NULL);
|
|
|
|
ok(SUCCEEDED(ret), "ParseDisplayName returned %x\n", ret);
|
|
|
|
|
|
|
|
ret = IShellFolder_BindToObject(desktopfolder, pidl_cwd, NULL, &IID_IShellFolder, (void**)¤tfolder);
|
|
|
|
ok(SUCCEEDED(ret), "BindToObject returned %x\n", ret);
|
|
|
|
|
|
|
|
CreateTestFile(".\\testfile");
|
|
|
|
|
|
|
|
ret = IShellFolder_ParseDisplayName(currentfolder, NULL, NULL, testfileW, NULL, &pidl_testfile, NULL);
|
|
|
|
ok(SUCCEEDED(ret), "ParseDisplayName returned %x\n", ret);
|
|
|
|
|
|
|
|
pidl_abstestfile = pILCombine(pidl_cwd, pidl_testfile);
|
|
|
|
|
|
|
|
ret = pSHCreateShellItem(NULL, NULL, NULL, &shellitem);
|
2009-05-21 18:24:29 +02:00
|
|
|
ok(ret == E_INVALIDARG, "SHCreateShellItem returned %x\n", ret);
|
2009-05-21 18:19:21 +02:00
|
|
|
|
|
|
|
if (0) /* crashes on Windows XP */
|
|
|
|
{
|
|
|
|
pSHCreateShellItem(NULL, NULL, pidl_cwd, NULL);
|
|
|
|
pSHCreateShellItem(pidl_cwd, NULL, NULL, &shellitem);
|
|
|
|
pSHCreateShellItem(NULL, currentfolder, NULL, &shellitem);
|
|
|
|
pSHCreateShellItem(pidl_cwd, currentfolder, NULL, &shellitem);
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = pSHCreateShellItem(NULL, NULL, pidl_cwd, &shellitem);
|
|
|
|
ok(SUCCEEDED(ret), "SHCreateShellItem returned %x\n", ret);
|
|
|
|
if (SUCCEEDED(ret))
|
|
|
|
{
|
|
|
|
ret = IShellItem_QueryInterface(shellitem, &IID_IPersistIDList, (void**)&persistidl);
|
|
|
|
ok(SUCCEEDED(ret), "QueryInterface returned %x\n", ret);
|
|
|
|
if (SUCCEEDED(ret))
|
|
|
|
{
|
|
|
|
ret = IPersistIDList_GetIDList(persistidl, &pidl_test);
|
|
|
|
ok(SUCCEEDED(ret), "GetIDList returned %x\n", ret);
|
|
|
|
if (SUCCEEDED(ret))
|
|
|
|
{
|
|
|
|
ok(ILIsEqual(pidl_cwd, pidl_test), "id lists are not equal\n");
|
|
|
|
pILFree(pidl_test);
|
|
|
|
}
|
|
|
|
IPersistIDList_Release(persistidl);
|
|
|
|
}
|
|
|
|
IShellItem_Release(shellitem);
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = pSHCreateShellItem(pidl_cwd, NULL, pidl_testfile, &shellitem);
|
2009-05-21 20:13:11 +02:00
|
|
|
ok(SUCCEEDED(ret), "SHCreateShellItem returned %x\n", ret);
|
2009-05-21 18:19:21 +02:00
|
|
|
if (SUCCEEDED(ret))
|
|
|
|
{
|
|
|
|
ret = IShellItem_QueryInterface(shellitem, &IID_IPersistIDList, (void**)&persistidl);
|
|
|
|
ok(SUCCEEDED(ret), "QueryInterface returned %x\n", ret);
|
|
|
|
if (SUCCEEDED(ret))
|
|
|
|
{
|
|
|
|
ret = IPersistIDList_GetIDList(persistidl, &pidl_test);
|
|
|
|
ok(SUCCEEDED(ret), "GetIDList returned %x\n", ret);
|
|
|
|
if (SUCCEEDED(ret))
|
|
|
|
{
|
|
|
|
ok(ILIsEqual(pidl_abstestfile, pidl_test), "id lists are not equal\n");
|
|
|
|
pILFree(pidl_test);
|
|
|
|
}
|
|
|
|
IPersistIDList_Release(persistidl);
|
|
|
|
}
|
2009-05-21 20:18:26 +02:00
|
|
|
|
|
|
|
ret = IShellItem_GetParent(shellitem, &shellitem2);
|
|
|
|
ok(SUCCEEDED(ret), "GetParent returned %x\n", ret);
|
|
|
|
if (SUCCEEDED(ret))
|
|
|
|
{
|
|
|
|
ret = IShellItem_QueryInterface(shellitem2, &IID_IPersistIDList, (void**)&persistidl);
|
|
|
|
ok(SUCCEEDED(ret), "QueryInterface returned %x\n", ret);
|
|
|
|
if (SUCCEEDED(ret))
|
|
|
|
{
|
|
|
|
ret = IPersistIDList_GetIDList(persistidl, &pidl_test);
|
|
|
|
ok(SUCCEEDED(ret), "GetIDList returned %x\n", ret);
|
|
|
|
if (SUCCEEDED(ret))
|
|
|
|
{
|
|
|
|
ok(ILIsEqual(pidl_cwd, pidl_test), "id lists are not equal\n");
|
|
|
|
pILFree(pidl_test);
|
|
|
|
}
|
|
|
|
IPersistIDList_Release(persistidl);
|
|
|
|
}
|
|
|
|
IShellItem_Release(shellitem2);
|
|
|
|
}
|
|
|
|
|
2009-05-21 18:19:21 +02:00
|
|
|
IShellItem_Release(shellitem);
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = pSHCreateShellItem(NULL, currentfolder, pidl_testfile, &shellitem);
|
2009-05-21 20:13:11 +02:00
|
|
|
ok(SUCCEEDED(ret), "SHCreateShellItem returned %x\n", ret);
|
2009-05-21 18:19:21 +02:00
|
|
|
if (SUCCEEDED(ret))
|
|
|
|
{
|
|
|
|
ret = IShellItem_QueryInterface(shellitem, &IID_IPersistIDList, (void**)&persistidl);
|
|
|
|
ok(SUCCEEDED(ret), "QueryInterface returned %x\n", ret);
|
|
|
|
if (SUCCEEDED(ret))
|
|
|
|
{
|
|
|
|
ret = IPersistIDList_GetIDList(persistidl, &pidl_test);
|
|
|
|
ok(SUCCEEDED(ret), "GetIDList returned %x\n", ret);
|
|
|
|
if (SUCCEEDED(ret))
|
|
|
|
{
|
|
|
|
ok(ILIsEqual(pidl_abstestfile, pidl_test), "id lists are not equal\n");
|
|
|
|
pILFree(pidl_test);
|
|
|
|
}
|
|
|
|
IPersistIDList_Release(persistidl);
|
|
|
|
}
|
|
|
|
IShellItem_Release(shellitem);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if a parent pidl and shellfolder are specified, the shellfolder is ignored */
|
|
|
|
ret = pSHCreateShellItem(pidl_cwd, desktopfolder, pidl_testfile, &shellitem);
|
2009-05-21 20:13:11 +02:00
|
|
|
ok(SUCCEEDED(ret), "SHCreateShellItem returned %x\n", ret);
|
2009-05-21 18:19:21 +02:00
|
|
|
if (SUCCEEDED(ret))
|
|
|
|
{
|
|
|
|
ret = IShellItem_QueryInterface(shellitem, &IID_IPersistIDList, (void**)&persistidl);
|
|
|
|
ok(SUCCEEDED(ret), "QueryInterface returned %x\n", ret);
|
|
|
|
if (SUCCEEDED(ret))
|
|
|
|
{
|
|
|
|
ret = IPersistIDList_GetIDList(persistidl, &pidl_test);
|
|
|
|
ok(SUCCEEDED(ret), "GetIDList returned %x\n", ret);
|
|
|
|
if (SUCCEEDED(ret))
|
|
|
|
{
|
|
|
|
ok(ILIsEqual(pidl_abstestfile, pidl_test), "id lists are not equal\n");
|
|
|
|
pILFree(pidl_test);
|
|
|
|
}
|
|
|
|
IPersistIDList_Release(persistidl);
|
|
|
|
}
|
|
|
|
IShellItem_Release(shellitem);
|
|
|
|
}
|
|
|
|
|
2010-07-18 14:34:56 +02:00
|
|
|
ret = pSHCreateShellItem(NULL, desktopfolder, pidl_testfile, &shellitem);
|
|
|
|
ok(SUCCEEDED(ret), "SHCreateShellItem returned %x\n", ret);
|
|
|
|
if (SUCCEEDED(ret))
|
|
|
|
{
|
|
|
|
ret = IShellItem_QueryInterface(shellitem, &IID_IPersistIDList, (void**)&persistidl);
|
|
|
|
ok(SUCCEEDED(ret), "QueryInterface returned %x\n", ret);
|
|
|
|
if (SUCCEEDED(ret))
|
|
|
|
{
|
|
|
|
ret = IPersistIDList_GetIDList(persistidl, &pidl_test);
|
|
|
|
ok(SUCCEEDED(ret), "GetIDList returned %x\n", ret);
|
|
|
|
if (SUCCEEDED(ret))
|
|
|
|
{
|
|
|
|
ok(ILIsEqual(pidl_testfile, pidl_test), "id lists are not equal\n");
|
|
|
|
pILFree(pidl_test);
|
|
|
|
}
|
|
|
|
IPersistIDList_Release(persistidl);
|
|
|
|
}
|
2010-08-24 10:56:20 +02:00
|
|
|
|
|
|
|
IShellItem_Release(shellitem);
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = pSHCreateShellItem(NULL, NULL, pidl_desktop, &shellitem);
|
|
|
|
ok(SUCCEEDED(ret), "SHCreateShellItem returned %x\n", ret);
|
|
|
|
if (SUCCEEDED(ret))
|
|
|
|
{
|
|
|
|
ret = IShellItem_GetParent(shellitem, &shellitem2);
|
|
|
|
ok(FAILED(ret), "Got 0x%08x\n", ret);
|
|
|
|
if(SUCCEEDED(ret)) IShellItem_Release(shellitem2);
|
2010-07-18 14:34:56 +02:00
|
|
|
IShellItem_Release(shellitem);
|
|
|
|
}
|
|
|
|
|
2010-07-22 20:17:03 +02:00
|
|
|
/* SHCreateItemFromParsingName */
|
|
|
|
if(pSHCreateItemFromParsingName)
|
|
|
|
{
|
|
|
|
if(0)
|
|
|
|
{
|
|
|
|
/* Crashes under windows 7 */
|
2011-02-10 20:57:20 +01:00
|
|
|
pSHCreateItemFromParsingName(NULL, NULL, &IID_IShellItem, NULL);
|
2010-07-22 20:17:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
shellitem = (void*)0xdeadbeef;
|
|
|
|
ret = pSHCreateItemFromParsingName(NULL, NULL, &IID_IShellItem, (void**)&shellitem);
|
|
|
|
ok(ret == E_INVALIDARG, "SHCreateItemFromParsingName returned %x\n", ret);
|
|
|
|
ok(shellitem == NULL, "shellitem was %p.\n", shellitem);
|
|
|
|
|
|
|
|
ret = pSHCreateItemFromParsingName(testfileW, NULL, &IID_IShellItem, (void**)&shellitem);
|
|
|
|
ok(ret == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND),
|
|
|
|
"SHCreateItemFromParsingName returned %x\n", ret);
|
|
|
|
if(SUCCEEDED(ret)) IShellItem_Release(shellitem);
|
|
|
|
|
|
|
|
lstrcpyW(fnbufW, curdirW);
|
|
|
|
myPathAddBackslashW(fnbufW);
|
|
|
|
lstrcatW(fnbufW, testfileW);
|
|
|
|
|
|
|
|
ret = pSHCreateItemFromParsingName(fnbufW, NULL, &IID_IShellItem, (void**)&shellitem);
|
|
|
|
ok(ret == S_OK, "SHCreateItemFromParsingName returned %x\n", ret);
|
|
|
|
if(SUCCEEDED(ret))
|
|
|
|
{
|
|
|
|
LPWSTR tmp_fname;
|
|
|
|
ret = IShellItem_GetDisplayName(shellitem, SIGDN_FILESYSPATH, &tmp_fname);
|
|
|
|
ok(ret == S_OK, "GetDisplayName returned %x\n", ret);
|
|
|
|
if(SUCCEEDED(ret))
|
|
|
|
{
|
|
|
|
ok(!lstrcmpW(fnbufW, tmp_fname), "strings not equal\n");
|
|
|
|
CoTaskMemFree(tmp_fname);
|
|
|
|
}
|
|
|
|
IShellItem_Release(shellitem);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
win_skip("No SHCreateItemFromParsingName\n");
|
|
|
|
|
2010-07-22 20:17:04 +02:00
|
|
|
|
|
|
|
/* SHCreateItemFromIDList */
|
|
|
|
if(pSHCreateItemFromIDList)
|
|
|
|
{
|
|
|
|
if(0)
|
|
|
|
{
|
|
|
|
/* Crashes under win7 */
|
2011-02-10 20:57:20 +01:00
|
|
|
pSHCreateItemFromIDList(NULL, &IID_IShellItem, NULL);
|
2010-07-22 20:17:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ret = pSHCreateItemFromIDList(NULL, &IID_IShellItem, (void**)&shellitem);
|
|
|
|
ok(ret == E_INVALIDARG, "SHCreateItemFromIDList returned %x\n", ret);
|
|
|
|
|
|
|
|
ret = pSHCreateItemFromIDList(pidl_cwd, &IID_IShellItem, (void**)&shellitem);
|
|
|
|
ok(ret == S_OK, "SHCreateItemFromIDList returned %x\n", ret);
|
|
|
|
if (SUCCEEDED(ret))
|
|
|
|
{
|
|
|
|
ret = IShellItem_QueryInterface(shellitem, &IID_IPersistIDList, (void**)&persistidl);
|
|
|
|
ok(ret == S_OK, "QueryInterface returned %x\n", ret);
|
|
|
|
if (SUCCEEDED(ret))
|
|
|
|
{
|
|
|
|
ret = IPersistIDList_GetIDList(persistidl, &pidl_test);
|
|
|
|
ok(ret == S_OK, "GetIDList returned %x\n", ret);
|
|
|
|
if (SUCCEEDED(ret))
|
|
|
|
{
|
|
|
|
ok(ILIsEqual(pidl_cwd, pidl_test), "id lists are not equal\n");
|
|
|
|
pILFree(pidl_test);
|
|
|
|
}
|
|
|
|
IPersistIDList_Release(persistidl);
|
|
|
|
}
|
|
|
|
IShellItem_Release(shellitem);
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = pSHCreateItemFromIDList(pidl_testfile, &IID_IShellItem, (void**)&shellitem);
|
|
|
|
ok(ret == S_OK, "SHCreateItemFromIDList returned %x\n", ret);
|
|
|
|
if (SUCCEEDED(ret))
|
|
|
|
{
|
|
|
|
ret = IShellItem_QueryInterface(shellitem, &IID_IPersistIDList, (void**)&persistidl);
|
|
|
|
ok(ret == S_OK, "QueryInterface returned %x\n", ret);
|
|
|
|
if (SUCCEEDED(ret))
|
|
|
|
{
|
|
|
|
ret = IPersistIDList_GetIDList(persistidl, &pidl_test);
|
|
|
|
ok(ret == S_OK, "GetIDList returned %x\n", ret);
|
|
|
|
if (SUCCEEDED(ret))
|
|
|
|
{
|
|
|
|
ok(ILIsEqual(pidl_testfile, pidl_test), "id lists are not equal\n");
|
|
|
|
pILFree(pidl_test);
|
|
|
|
}
|
|
|
|
IPersistIDList_Release(persistidl);
|
|
|
|
}
|
|
|
|
IShellItem_Release(shellitem);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
win_skip("No SHCreateItemFromIDList\n");
|
|
|
|
|
2009-05-21 18:19:21 +02:00
|
|
|
DeleteFileA(".\\testfile");
|
|
|
|
pILFree(pidl_abstestfile);
|
|
|
|
pILFree(pidl_testfile);
|
2010-08-24 10:56:20 +02:00
|
|
|
pILFree(pidl_desktop);
|
2009-05-21 18:19:21 +02:00
|
|
|
pILFree(pidl_cwd);
|
|
|
|
IShellFolder_Release(currentfolder);
|
|
|
|
IShellFolder_Release(desktopfolder);
|
|
|
|
}
|
2008-03-03 23:44:52 +01:00
|
|
|
|
2010-07-22 20:17:02 +02:00
|
|
|
static void test_SHGetNameFromIDList(void)
|
|
|
|
{
|
|
|
|
IShellItem *shellitem;
|
|
|
|
LPITEMIDLIST pidl;
|
|
|
|
LPWSTR name_string;
|
|
|
|
HRESULT hres;
|
|
|
|
UINT i;
|
|
|
|
static const DWORD flags[] = {
|
|
|
|
SIGDN_NORMALDISPLAY, SIGDN_PARENTRELATIVEPARSING,
|
|
|
|
SIGDN_DESKTOPABSOLUTEPARSING,SIGDN_PARENTRELATIVEEDITING,
|
|
|
|
SIGDN_DESKTOPABSOLUTEEDITING, /*SIGDN_FILESYSPATH, SIGDN_URL, */
|
|
|
|
SIGDN_PARENTRELATIVEFORADDRESSBAR,SIGDN_PARENTRELATIVE, -1234};
|
|
|
|
|
|
|
|
if(!pSHGetNameFromIDList)
|
|
|
|
{
|
|
|
|
win_skip("SHGetNameFromIDList missing.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* These should be available on any platform that passed the above test. */
|
|
|
|
ok(pSHCreateShellItem != NULL, "SHCreateShellItem missing.\n");
|
|
|
|
ok(pSHBindToParent != NULL, "SHBindToParent missing.\n");
|
|
|
|
ok(pSHGetSpecialFolderLocation != NULL, "SHGetSpecialFolderLocation missing.\n");
|
|
|
|
ok(pStrRetToBufW != NULL, "StrRetToBufW missing.\n");
|
|
|
|
|
|
|
|
if(0)
|
|
|
|
{
|
|
|
|
/* Crashes under win7 */
|
2011-02-10 20:57:20 +01:00
|
|
|
pSHGetNameFromIDList(NULL, 0, NULL);
|
2010-07-22 20:17:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
hres = pSHGetNameFromIDList(NULL, 0, &name_string);
|
|
|
|
ok(hres == E_INVALIDARG, "Got 0x%08x\n", hres);
|
|
|
|
|
|
|
|
/* Test the desktop */
|
|
|
|
hres = pSHGetSpecialFolderLocation(NULL, CSIDL_DESKTOP, &pidl);
|
|
|
|
ok(hres == S_OK, "Got 0x%08x\n", hres);
|
|
|
|
hres = pSHCreateShellItem(NULL, NULL, pidl, &shellitem);
|
|
|
|
ok(hres == S_OK, "Got 0x%08x\n", hres);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
{
|
|
|
|
WCHAR *nameSI, *nameSH;
|
|
|
|
WCHAR buf[MAX_PATH];
|
|
|
|
HRESULT hrSI, hrSH, hrSF;
|
|
|
|
STRRET strret;
|
|
|
|
IShellFolder *psf;
|
|
|
|
BOOL res;
|
|
|
|
|
|
|
|
SHGetDesktopFolder(&psf);
|
|
|
|
for(i = 0; flags[i] != -1234; i++)
|
|
|
|
{
|
|
|
|
hrSI = IShellItem_GetDisplayName(shellitem, flags[i], &nameSI);
|
|
|
|
ok(hrSI == S_OK, "Got 0x%08x\n", hrSI);
|
|
|
|
hrSH = pSHGetNameFromIDList(pidl, flags[i], &nameSH);
|
|
|
|
ok(hrSH == S_OK, "Got 0x%08x\n", hrSH);
|
|
|
|
hrSF = IShellFolder_GetDisplayNameOf(psf, pidl, flags[i] & 0xffff, &strret);
|
|
|
|
ok(hrSF == S_OK, "Got 0x%08x\n", hrSF);
|
|
|
|
|
|
|
|
if(SUCCEEDED(hrSI) && SUCCEEDED(hrSH))
|
|
|
|
ok(!lstrcmpW(nameSI, nameSH), "Strings differ.\n");
|
|
|
|
|
|
|
|
if(SUCCEEDED(hrSF))
|
|
|
|
{
|
|
|
|
pStrRetToBufW(&strret, NULL, buf, MAX_PATH);
|
|
|
|
if(SUCCEEDED(hrSI))
|
|
|
|
ok(!lstrcmpW(nameSI, buf), "Strings differ.\n");
|
|
|
|
if(SUCCEEDED(hrSF))
|
|
|
|
ok(!lstrcmpW(nameSI, buf), "Strings differ.\n");
|
|
|
|
}
|
|
|
|
if(SUCCEEDED(hrSI)) CoTaskMemFree(nameSI);
|
|
|
|
if(SUCCEEDED(hrSH)) CoTaskMemFree(nameSH);
|
|
|
|
}
|
|
|
|
IShellFolder_Release(psf);
|
|
|
|
|
2010-08-03 15:50:47 +02:00
|
|
|
if(pSHGetPathFromIDListW){
|
|
|
|
hrSI = pSHGetNameFromIDList(pidl, SIGDN_FILESYSPATH, &nameSI);
|
|
|
|
ok(hrSI == S_OK, "Got 0x%08x\n", hrSI);
|
|
|
|
res = pSHGetPathFromIDListW(pidl, buf);
|
|
|
|
ok(res == TRUE, "Got %d\n", res);
|
|
|
|
if(SUCCEEDED(hrSI) && res)
|
|
|
|
ok(!lstrcmpW(nameSI, buf), "Strings differ.\n");
|
|
|
|
if(SUCCEEDED(hrSI)) CoTaskMemFree(nameSI);
|
|
|
|
}else
|
|
|
|
win_skip("pSHGetPathFromIDListW not available\n");
|
2010-07-22 20:17:02 +02:00
|
|
|
|
|
|
|
hres = pSHGetNameFromIDList(pidl, SIGDN_URL, &name_string);
|
|
|
|
todo_wine ok(hres == S_OK, "Got 0x%08x\n", hres);
|
|
|
|
if(SUCCEEDED(hres)) CoTaskMemFree(name_string);
|
|
|
|
|
|
|
|
IShellItem_Release(shellitem);
|
|
|
|
}
|
|
|
|
pILFree(pidl);
|
|
|
|
|
|
|
|
/* Test the control panel */
|
|
|
|
hres = pSHGetSpecialFolderLocation(NULL, CSIDL_CONTROLS, &pidl);
|
|
|
|
ok(hres == S_OK, "Got 0x%08x\n", hres);
|
|
|
|
hres = pSHCreateShellItem(NULL, NULL, pidl, &shellitem);
|
|
|
|
ok(hres == S_OK, "Got 0x%08x\n", hres);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
{
|
|
|
|
WCHAR *nameSI, *nameSH;
|
|
|
|
WCHAR buf[MAX_PATH];
|
|
|
|
HRESULT hrSI, hrSH, hrSF;
|
|
|
|
STRRET strret;
|
|
|
|
IShellFolder *psf;
|
|
|
|
BOOL res;
|
|
|
|
|
|
|
|
SHGetDesktopFolder(&psf);
|
|
|
|
for(i = 0; flags[i] != -1234; i++)
|
|
|
|
{
|
|
|
|
hrSI = IShellItem_GetDisplayName(shellitem, flags[i], &nameSI);
|
|
|
|
ok(hrSI == S_OK, "Got 0x%08x\n", hrSI);
|
|
|
|
hrSH = pSHGetNameFromIDList(pidl, flags[i], &nameSH);
|
|
|
|
ok(hrSH == S_OK, "Got 0x%08x\n", hrSH);
|
|
|
|
hrSF = IShellFolder_GetDisplayNameOf(psf, pidl, flags[i] & 0xffff, &strret);
|
|
|
|
ok(hrSF == S_OK, "Got 0x%08x\n", hrSF);
|
|
|
|
|
|
|
|
if(SUCCEEDED(hrSI) && SUCCEEDED(hrSH))
|
|
|
|
ok(!lstrcmpW(nameSI, nameSH), "Strings differ.\n");
|
|
|
|
|
|
|
|
if(SUCCEEDED(hrSF))
|
|
|
|
{
|
|
|
|
pStrRetToBufW(&strret, NULL, buf, MAX_PATH);
|
|
|
|
if(SUCCEEDED(hrSI))
|
|
|
|
ok(!lstrcmpW(nameSI, buf), "Strings differ.\n");
|
|
|
|
if(SUCCEEDED(hrSF))
|
|
|
|
ok(!lstrcmpW(nameSI, buf), "Strings differ.\n");
|
|
|
|
}
|
|
|
|
if(SUCCEEDED(hrSI)) CoTaskMemFree(nameSI);
|
|
|
|
if(SUCCEEDED(hrSH)) CoTaskMemFree(nameSH);
|
|
|
|
}
|
|
|
|
IShellFolder_Release(psf);
|
|
|
|
|
2010-08-03 15:50:47 +02:00
|
|
|
if(pSHGetPathFromIDListW){
|
|
|
|
hrSI = pSHGetNameFromIDList(pidl, SIGDN_FILESYSPATH, &nameSI);
|
|
|
|
ok(hrSI == E_INVALIDARG, "Got 0x%08x\n", hrSI);
|
|
|
|
res = pSHGetPathFromIDListW(pidl, buf);
|
|
|
|
ok(res == FALSE, "Got %d\n", res);
|
|
|
|
if(SUCCEEDED(hrSI) && res)
|
|
|
|
ok(!lstrcmpW(nameSI, buf), "Strings differ.\n");
|
|
|
|
if(SUCCEEDED(hrSI)) CoTaskMemFree(nameSI);
|
|
|
|
}else
|
|
|
|
win_skip("pSHGetPathFromIDListW not available\n");
|
2010-07-22 20:17:02 +02:00
|
|
|
|
|
|
|
hres = pSHGetNameFromIDList(pidl, SIGDN_URL, &name_string);
|
|
|
|
todo_wine ok(hres == E_NOTIMPL /* Win7 */ || hres == S_OK /* Vista */,
|
|
|
|
"Got 0x%08x\n", hres);
|
|
|
|
if(SUCCEEDED(hres)) CoTaskMemFree(name_string);
|
|
|
|
|
|
|
|
IShellItem_Release(shellitem);
|
|
|
|
}
|
|
|
|
pILFree(pidl);
|
|
|
|
}
|
|
|
|
|
2010-07-22 20:17:05 +02:00
|
|
|
static void test_SHGetItemFromDataObject(void)
|
|
|
|
{
|
|
|
|
IShellFolder *psfdesktop;
|
|
|
|
IShellItem *psi;
|
|
|
|
IShellView *psv;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
if(!pSHGetItemFromDataObject)
|
|
|
|
{
|
|
|
|
win_skip("No SHGetItemFromDataObject.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(0)
|
|
|
|
{
|
|
|
|
/* Crashes under win7 */
|
2011-02-10 20:57:20 +01:00
|
|
|
pSHGetItemFromDataObject(NULL, 0, &IID_IShellItem, NULL);
|
2010-07-22 20:17:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
hres = pSHGetItemFromDataObject(NULL, 0, &IID_IShellItem, (void**)&psv);
|
|
|
|
ok(hres == E_INVALIDARG, "got 0x%08x\n", hres);
|
|
|
|
|
|
|
|
SHGetDesktopFolder(&psfdesktop);
|
|
|
|
|
|
|
|
hres = IShellFolder_CreateViewObject(psfdesktop, NULL, &IID_IShellView, (void**)&psv);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
{
|
|
|
|
IEnumIDList *peidl;
|
|
|
|
IDataObject *pdo;
|
|
|
|
SHCONTF enum_flags;
|
|
|
|
|
|
|
|
enum_flags = SHCONTF_NONFOLDERS | SHCONTF_FOLDERS | SHCONTF_INCLUDEHIDDEN;
|
|
|
|
hres = IShellFolder_EnumObjects(psfdesktop, NULL, enum_flags, &peidl);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
{
|
|
|
|
LPITEMIDLIST apidl[5];
|
|
|
|
UINT count = 0, i;
|
|
|
|
|
|
|
|
for(count = 0; count < 5; count++)
|
|
|
|
if(IEnumIDList_Next(peidl, 1, &apidl[count], NULL) != S_OK)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if(count)
|
|
|
|
{
|
|
|
|
hres = IShellFolder_GetUIObjectOf(psfdesktop, NULL, 1, (LPCITEMIDLIST*)apidl,
|
|
|
|
&IID_IDataObject, NULL, (void**)&pdo);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
{
|
|
|
|
hres = pSHGetItemFromDataObject(pdo, DOGIF_DEFAULT, &IID_IShellItem, (void**)&psi);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
if(SUCCEEDED(hres)) IShellItem_Release(psi);
|
|
|
|
hres = pSHGetItemFromDataObject(pdo, DOGIF_TRAVERSE_LINK, &IID_IShellItem, (void**)&psi);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
if(SUCCEEDED(hres)) IShellItem_Release(psi);
|
|
|
|
hres = pSHGetItemFromDataObject(pdo, DOGIF_NO_HDROP, &IID_IShellItem, (void**)&psi);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
if(SUCCEEDED(hres)) IShellItem_Release(psi);
|
|
|
|
hres = pSHGetItemFromDataObject(pdo, DOGIF_NO_URL, &IID_IShellItem, (void**)&psi);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
if(SUCCEEDED(hres)) IShellItem_Release(psi);
|
|
|
|
hres = pSHGetItemFromDataObject(pdo, DOGIF_ONLY_IF_ONE, &IID_IShellItem, (void**)&psi);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
if(SUCCEEDED(hres)) IShellItem_Release(psi);
|
|
|
|
|
|
|
|
IDataObject_Release(pdo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
skip("No file(s) found - skipping single-file test.\n");
|
|
|
|
|
|
|
|
if(count > 1)
|
|
|
|
{
|
|
|
|
hres = IShellFolder_GetUIObjectOf(psfdesktop, NULL, count, (LPCITEMIDLIST*)apidl,
|
|
|
|
&IID_IDataObject, NULL, (void**)&pdo);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
{
|
|
|
|
hres = pSHGetItemFromDataObject(pdo, DOGIF_DEFAULT, &IID_IShellItem, (void**)&psi);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
if(SUCCEEDED(hres)) IShellItem_Release(psi);
|
|
|
|
hres = pSHGetItemFromDataObject(pdo, DOGIF_TRAVERSE_LINK, &IID_IShellItem, (void**)&psi);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
if(SUCCEEDED(hres)) IShellItem_Release(psi);
|
|
|
|
hres = pSHGetItemFromDataObject(pdo, DOGIF_NO_HDROP, &IID_IShellItem, (void**)&psi);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
if(SUCCEEDED(hres)) IShellItem_Release(psi);
|
|
|
|
hres = pSHGetItemFromDataObject(pdo, DOGIF_NO_URL, &IID_IShellItem, (void**)&psi);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
if(SUCCEEDED(hres)) IShellItem_Release(psi);
|
|
|
|
hres = pSHGetItemFromDataObject(pdo, DOGIF_ONLY_IF_ONE, &IID_IShellItem, (void**)&psi);
|
|
|
|
ok(hres == E_FAIL, "got 0x%08x\n", hres);
|
|
|
|
if(SUCCEEDED(hres)) IShellItem_Release(psi);
|
2010-07-22 20:17:06 +02:00
|
|
|
IDataObject_Release(pdo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
skip("zero or one file found - skipping multi-file test.\n");
|
|
|
|
|
|
|
|
for(i = 0; i < count; i++)
|
|
|
|
pILFree(apidl[i]);
|
|
|
|
|
|
|
|
IEnumIDList_Release(peidl);
|
|
|
|
}
|
|
|
|
|
|
|
|
IShellView_Release(psv);
|
|
|
|
}
|
|
|
|
|
|
|
|
IShellFolder_Release(psfdesktop);
|
|
|
|
}
|
|
|
|
|
2010-07-25 19:08:15 +02:00
|
|
|
static void test_ShellItemCompare(void)
|
|
|
|
{
|
|
|
|
IShellItem *psi[9]; /* a\a, a\b, a\c, b\a, .. */
|
2010-09-26 00:14:44 +02:00
|
|
|
IShellItem *psi_a = NULL, *psi_b = NULL, *psi_c = NULL;
|
2010-07-25 19:08:15 +02:00
|
|
|
IShellFolder *psf_desktop, *psf_current;
|
|
|
|
LPITEMIDLIST pidl_cwd;
|
|
|
|
WCHAR curdirW[MAX_PATH];
|
|
|
|
BOOL failed;
|
|
|
|
HRESULT hr;
|
|
|
|
static const WCHAR filesW[][9] = {
|
|
|
|
{'a','\\','a',0}, {'a','\\','b',0}, {'a','\\','c',0},
|
|
|
|
{'b','\\','a',0}, {'b','\\','b',0}, {'b','\\','c',0},
|
|
|
|
{'c','\\','a',0}, {'c','\\','b',0}, {'c','\\','c',0} };
|
|
|
|
int order;
|
|
|
|
UINT i;
|
|
|
|
|
|
|
|
if(!pSHCreateShellItem)
|
|
|
|
{
|
|
|
|
win_skip("SHCreateShellItem missing.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
GetCurrentDirectoryW(MAX_PATH, curdirW);
|
|
|
|
if(!lstrlenW(curdirW))
|
|
|
|
{
|
|
|
|
skip("Failed to get current directory, skipping.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
CreateDirectoryA(".\\a", NULL);
|
|
|
|
CreateDirectoryA(".\\b", NULL);
|
|
|
|
CreateDirectoryA(".\\c", NULL);
|
|
|
|
CreateTestFile(".\\a\\a");
|
|
|
|
CreateTestFile(".\\a\\b");
|
|
|
|
CreateTestFile(".\\a\\c");
|
|
|
|
CreateTestFile(".\\b\\a");
|
|
|
|
CreateTestFile(".\\b\\b");
|
|
|
|
CreateTestFile(".\\b\\c");
|
|
|
|
CreateTestFile(".\\c\\a");
|
|
|
|
CreateTestFile(".\\c\\b");
|
|
|
|
CreateTestFile(".\\c\\c");
|
|
|
|
|
|
|
|
SHGetDesktopFolder(&psf_desktop);
|
|
|
|
hr = IShellFolder_ParseDisplayName(psf_desktop, NULL, NULL, curdirW, NULL, &pidl_cwd, NULL);
|
|
|
|
ok(SUCCEEDED(hr), "ParseDisplayName returned %x\n", hr);
|
|
|
|
hr = IShellFolder_BindToObject(psf_desktop, pidl_cwd, NULL, &IID_IShellFolder, (void**)&psf_current);
|
|
|
|
ok(SUCCEEDED(hr), "BindToObject returned %x\n", hr);
|
|
|
|
IShellFolder_Release(psf_desktop);
|
2011-01-22 01:43:59 +01:00
|
|
|
ILFree(pidl_cwd);
|
2010-07-25 19:08:15 +02:00
|
|
|
|
|
|
|
/* Generate ShellItems for the files */
|
2011-01-22 01:43:59 +01:00
|
|
|
memset(&psi, 0, sizeof(psi));
|
2010-07-25 19:08:15 +02:00
|
|
|
failed = FALSE;
|
|
|
|
for(i = 0; i < 9; i++)
|
|
|
|
{
|
|
|
|
LPITEMIDLIST pidl_testfile = NULL;
|
|
|
|
|
|
|
|
hr = IShellFolder_ParseDisplayName(psf_current, NULL, NULL, (LPWSTR)filesW[i],
|
|
|
|
NULL, &pidl_testfile, NULL);
|
|
|
|
ok(SUCCEEDED(hr), "ParseDisplayName returned %x\n", hr);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = pSHCreateShellItem(NULL, NULL, pidl_testfile, &psi[i]);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
pILFree(pidl_testfile);
|
|
|
|
}
|
|
|
|
if(FAILED(hr)) failed = TRUE;
|
|
|
|
}
|
|
|
|
if(failed)
|
|
|
|
{
|
2010-08-24 10:04:07 +02:00
|
|
|
skip("Failed to create all shellitems.\n");
|
2010-07-25 19:08:15 +02:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Generate ShellItems for the folders */
|
|
|
|
hr = IShellItem_GetParent(psi[0], &psi_a);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
if(FAILED(hr)) failed = TRUE;
|
|
|
|
hr = IShellItem_GetParent(psi[3], &psi_b);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
if(FAILED(hr)) failed = TRUE;
|
|
|
|
hr = IShellItem_GetParent(psi[6], &psi_c);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
if(FAILED(hr)) failed = TRUE;
|
|
|
|
|
|
|
|
if(failed)
|
|
|
|
{
|
2010-08-24 10:04:07 +02:00
|
|
|
skip("Failed to create shellitems.\n");
|
2010-07-25 19:08:15 +02:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(0)
|
|
|
|
{
|
|
|
|
/* Crashes on native (win7, winxp) */
|
2011-02-10 20:57:20 +01:00
|
|
|
IShellItem_Compare(psi_a, NULL, 0, NULL);
|
|
|
|
IShellItem_Compare(psi_a, psi_b, 0, NULL);
|
|
|
|
IShellItem_Compare(psi_a, NULL, 0, &order);
|
2010-07-25 19:08:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Basics */
|
|
|
|
for(i = 0; i < 9; i++)
|
|
|
|
{
|
|
|
|
hr = IShellItem_Compare(psi[i], psi[i], SICHINT_DISPLAY, &order);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
ok(order == 0, "Got order %d\n", order);
|
|
|
|
hr = IShellItem_Compare(psi[i], psi[i], SICHINT_CANONICAL, &order);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
ok(order == 0, "Got order %d\n", order);
|
|
|
|
hr = IShellItem_Compare(psi[i], psi[i], SICHINT_ALLFIELDS, &order);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
ok(order == 0, "Got order %d\n", order);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Order */
|
|
|
|
/* a\b:a\a , a\b:a\c, a\b:a\b */
|
|
|
|
hr = IShellItem_Compare(psi[1], psi[0], SICHINT_DISPLAY, &order);
|
|
|
|
ok(hr == S_FALSE, "Got 0x%08x\n", hr);
|
|
|
|
ok(order == 1, "Got order %d\n", order);
|
|
|
|
hr = IShellItem_Compare(psi[1], psi[2], SICHINT_DISPLAY, &order);
|
|
|
|
ok(hr == S_FALSE, "Got 0x%08x\n", hr);
|
|
|
|
ok(order == -1, "Got order %d\n", order);
|
|
|
|
hr = IShellItem_Compare(psi[1], psi[1], SICHINT_DISPLAY, &order);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
ok(order == 0, "Got order %d\n", order);
|
|
|
|
|
|
|
|
/* b\b:a\b, b\b:c\b, b\b:c\b */
|
|
|
|
hr = IShellItem_Compare(psi[4], psi[1], SICHINT_DISPLAY, &order);
|
|
|
|
ok(hr == S_FALSE, "Got 0x%08x\n", hr);
|
|
|
|
ok(order == 1, "Got order %d\n", order);
|
|
|
|
hr = IShellItem_Compare(psi[4], psi[7], SICHINT_DISPLAY, &order);
|
|
|
|
ok(hr == S_FALSE, "Got 0x%08x\n", hr);
|
|
|
|
ok(order == -1, "Got order %d\n", order);
|
|
|
|
hr = IShellItem_Compare(psi[4], psi[4], SICHINT_DISPLAY, &order);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
ok(order == 0, "Got order %d\n", order);
|
|
|
|
|
|
|
|
/* b:a\a, b:a\c, b:a\b */
|
|
|
|
hr = IShellItem_Compare(psi_b, psi[0], SICHINT_DISPLAY, &order);
|
|
|
|
ok(hr == S_FALSE, "Got 0x%08x\n", hr);
|
|
|
|
todo_wine ok(order == 1, "Got order %d\n", order);
|
|
|
|
hr = IShellItem_Compare(psi_b, psi[2], SICHINT_DISPLAY, &order);
|
|
|
|
ok(hr == S_FALSE, "Got 0x%08x\n", hr);
|
|
|
|
todo_wine ok(order == 1, "Got order %d\n", order);
|
|
|
|
hr = IShellItem_Compare(psi_b, psi[1], SICHINT_DISPLAY, &order);
|
|
|
|
ok(hr == S_FALSE, "Got 0x%08x\n", hr);
|
|
|
|
todo_wine ok(order == 1, "Got order %d\n", order);
|
|
|
|
|
|
|
|
/* b:c\a, b:c\c, b:c\b */
|
|
|
|
hr = IShellItem_Compare(psi_b, psi[6], SICHINT_DISPLAY, &order);
|
|
|
|
ok(hr == S_FALSE, "Got 0x%08x\n", hr);
|
|
|
|
ok(order == -1, "Got order %d\n", order);
|
|
|
|
hr = IShellItem_Compare(psi_b, psi[8], SICHINT_DISPLAY, &order);
|
|
|
|
ok(hr == S_FALSE, "Got 0x%08x\n", hr);
|
|
|
|
ok(order == -1, "Got order %d\n", order);
|
|
|
|
hr = IShellItem_Compare(psi_b, psi[7], SICHINT_DISPLAY, &order);
|
|
|
|
ok(hr == S_FALSE, "Got 0x%08x\n", hr);
|
|
|
|
ok(order == -1, "Got order %d\n", order);
|
|
|
|
|
|
|
|
/* a\b:a\a , a\b:a\c, a\b:a\b */
|
|
|
|
hr = IShellItem_Compare(psi[1], psi[0], SICHINT_CANONICAL, &order);
|
|
|
|
ok(hr == S_FALSE, "Got 0x%08x\n", hr);
|
|
|
|
ok(order == 1, "Got order %d\n", order);
|
|
|
|
hr = IShellItem_Compare(psi[1], psi[2], SICHINT_CANONICAL, &order);
|
|
|
|
ok(hr == S_FALSE, "Got 0x%08x\n", hr);
|
|
|
|
ok(order == -1, "Got order %d\n", order);
|
|
|
|
hr = IShellItem_Compare(psi[1], psi[1], SICHINT_CANONICAL, &order);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
ok(order == 0, "Got order %d\n", order);
|
|
|
|
|
|
|
|
/* b\b:a\b, b\b:c\b, b\b:c\b */
|
|
|
|
hr = IShellItem_Compare(psi[4], psi[1], SICHINT_CANONICAL, &order);
|
|
|
|
ok(hr == S_FALSE, "Got 0x%08x\n", hr);
|
|
|
|
ok(order == 1, "Got order %d\n", order);
|
|
|
|
hr = IShellItem_Compare(psi[4], psi[7], SICHINT_CANONICAL, &order);
|
|
|
|
ok(hr == S_FALSE, "Got 0x%08x\n", hr);
|
|
|
|
ok(order == -1, "Got order %d\n", order);
|
|
|
|
hr = IShellItem_Compare(psi[4], psi[4], SICHINT_CANONICAL, &order);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
ok(order == 0, "Got order %d\n", order);
|
|
|
|
|
|
|
|
/* b:a\a, b:a\c, b:a\b */
|
|
|
|
hr = IShellItem_Compare(psi_b, psi[0], SICHINT_CANONICAL, &order);
|
|
|
|
ok(hr == S_FALSE, "Got 0x%08x\n", hr);
|
|
|
|
todo_wine ok(order == 1, "Got order %d\n", order);
|
|
|
|
hr = IShellItem_Compare(psi_b, psi[2], SICHINT_CANONICAL, &order);
|
|
|
|
ok(hr == S_FALSE, "Got 0x%08x\n", hr);
|
|
|
|
todo_wine ok(order == 1, "Got order %d\n", order);
|
|
|
|
hr = IShellItem_Compare(psi_b, psi[1], SICHINT_CANONICAL, &order);
|
|
|
|
ok(hr == S_FALSE, "Got 0x%08x\n", hr);
|
|
|
|
todo_wine ok(order == 1, "Got order %d\n", order);
|
|
|
|
|
|
|
|
/* b:c\a, b:c\c, b:c\b */
|
|
|
|
hr = IShellItem_Compare(psi_b, psi[6], SICHINT_CANONICAL, &order);
|
|
|
|
ok(hr == S_FALSE, "Got 0x%08x\n", hr);
|
|
|
|
ok(order == -1, "Got order %d\n", order);
|
|
|
|
hr = IShellItem_Compare(psi_b, psi[8], SICHINT_CANONICAL, &order);
|
|
|
|
ok(hr == S_FALSE, "Got 0x%08x\n", hr);
|
|
|
|
ok(order == -1, "Got order %d\n", order);
|
|
|
|
hr = IShellItem_Compare(psi_b, psi[7], SICHINT_CANONICAL, &order);
|
|
|
|
ok(hr == S_FALSE, "Got 0x%08x\n", hr);
|
|
|
|
ok(order == -1, "Got order %d\n", order);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
IShellFolder_Release(psf_current);
|
|
|
|
|
|
|
|
DeleteFileA(".\\a\\a");
|
|
|
|
DeleteFileA(".\\a\\b");
|
|
|
|
DeleteFileA(".\\a\\c");
|
|
|
|
DeleteFileA(".\\b\\a");
|
|
|
|
DeleteFileA(".\\b\\b");
|
|
|
|
DeleteFileA(".\\b\\c");
|
|
|
|
DeleteFileA(".\\c\\a");
|
|
|
|
DeleteFileA(".\\c\\b");
|
|
|
|
DeleteFileA(".\\c\\c");
|
|
|
|
RemoveDirectoryA(".\\a");
|
|
|
|
RemoveDirectoryA(".\\b");
|
|
|
|
RemoveDirectoryA(".\\c");
|
|
|
|
|
|
|
|
if(psi_a) IShellItem_Release(psi_a);
|
|
|
|
if(psi_b) IShellItem_Release(psi_b);
|
|
|
|
if(psi_c) IShellItem_Release(psi_c);
|
|
|
|
|
|
|
|
for(i = 0; i < 9; i++)
|
|
|
|
if(psi[i]) IShellItem_Release(psi[i]);
|
|
|
|
}
|
|
|
|
|
2010-07-22 20:17:06 +02:00
|
|
|
/**************************************************************/
|
|
|
|
/* IUnknown implementation for counting QueryInterface calls. */
|
|
|
|
typedef struct {
|
2011-04-26 23:45:13 +02:00
|
|
|
IUnknown IUnknown_iface;
|
2010-07-22 20:17:06 +02:00
|
|
|
struct if_count {
|
|
|
|
REFIID id;
|
|
|
|
LONG count;
|
|
|
|
} *ifaces;
|
|
|
|
LONG unknown;
|
|
|
|
} IUnknownImpl;
|
|
|
|
|
2011-04-26 23:45:13 +02:00
|
|
|
static inline IUnknownImpl *impl_from_IUnknown(IUnknown *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, IUnknownImpl, IUnknown_iface);
|
|
|
|
}
|
|
|
|
|
2010-07-22 20:17:06 +02:00
|
|
|
static HRESULT WINAPI unk_fnQueryInterface(IUnknown *iunk, REFIID riid, void** punk)
|
|
|
|
{
|
2011-04-26 23:45:13 +02:00
|
|
|
IUnknownImpl *This = impl_from_IUnknown(iunk);
|
2010-07-22 20:17:06 +02:00
|
|
|
UINT i, found;
|
|
|
|
for(i = found = 0; This->ifaces[i].id != NULL; i++)
|
|
|
|
{
|
|
|
|
if(IsEqualIID(This->ifaces[i].id, riid))
|
|
|
|
{
|
|
|
|
This->ifaces[i].count++;
|
|
|
|
found = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!found)
|
|
|
|
This->unknown++;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI unk_fnAddRef(IUnknown *iunk)
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI unk_fnRelease(IUnknown *iunk)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2010-10-01 13:41:42 +02:00
|
|
|
static const IUnknownVtbl vt_IUnknown = {
|
2010-07-22 20:17:06 +02:00
|
|
|
unk_fnQueryInterface,
|
|
|
|
unk_fnAddRef,
|
|
|
|
unk_fnRelease
|
|
|
|
};
|
|
|
|
|
|
|
|
static void test_SHGetIDListFromObject(void)
|
|
|
|
{
|
|
|
|
IUnknownImpl *punkimpl;
|
|
|
|
IShellFolder *psfdesktop;
|
|
|
|
IShellView *psv;
|
|
|
|
LPITEMIDLIST pidl, pidl_desktop;
|
|
|
|
HRESULT hres;
|
|
|
|
UINT i;
|
|
|
|
struct if_count ifaces[] =
|
|
|
|
{ {&IID_IPersistIDList, 0},
|
|
|
|
{&IID_IPersistFolder2, 0},
|
|
|
|
{&IID_IDataObject, 0},
|
|
|
|
{&IID_IParentAndItem, 0},
|
|
|
|
{&IID_IFolderView, 0},
|
|
|
|
{NULL, 0} };
|
|
|
|
|
|
|
|
if(!pSHGetIDListFromObject)
|
|
|
|
{
|
|
|
|
win_skip("SHGetIDListFromObject missing.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ok(pSHGetSpecialFolderLocation != NULL, "SHGetSpecialFolderLocation missing.\n");
|
|
|
|
|
|
|
|
if(0)
|
|
|
|
{
|
|
|
|
/* Crashes native */
|
|
|
|
pSHGetIDListFromObject(NULL, NULL);
|
|
|
|
pSHGetIDListFromObject((void*)0xDEADBEEF, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = pSHGetIDListFromObject(NULL, &pidl);
|
|
|
|
ok(hres == E_NOINTERFACE, "Got %x\n", hres);
|
|
|
|
|
|
|
|
punkimpl = HeapAlloc(GetProcessHeap(), 0, sizeof(IUnknownImpl));
|
2011-04-26 23:45:13 +02:00
|
|
|
punkimpl->IUnknown_iface.lpVtbl = &vt_IUnknown;
|
2010-07-22 20:17:06 +02:00
|
|
|
punkimpl->ifaces = ifaces;
|
|
|
|
punkimpl->unknown = 0;
|
|
|
|
|
|
|
|
hres = pSHGetIDListFromObject((IUnknown*)punkimpl, &pidl);
|
|
|
|
ok(hres == E_NOINTERFACE, "Got %x\n", hres);
|
|
|
|
ok(ifaces[0].count, "interface not requested.\n");
|
|
|
|
ok(ifaces[1].count, "interface not requested.\n");
|
|
|
|
ok(ifaces[2].count, "interface not requested.\n");
|
|
|
|
todo_wine
|
|
|
|
ok(ifaces[3].count || broken(!ifaces[3].count /*vista*/),
|
|
|
|
"interface not requested.\n");
|
|
|
|
ok(ifaces[4].count || broken(!ifaces[4].count /*vista*/),
|
|
|
|
"interface not requested.\n");
|
|
|
|
|
|
|
|
ok(!punkimpl->unknown, "Got %d unknown.\n", punkimpl->unknown);
|
|
|
|
HeapFree(GetProcessHeap(), 0, punkimpl);
|
|
|
|
|
|
|
|
pidl_desktop = NULL;
|
|
|
|
pSHGetSpecialFolderLocation(NULL, CSIDL_DESKTOP, &pidl_desktop);
|
|
|
|
ok(pidl_desktop != NULL, "Failed to get desktop pidl.\n");
|
|
|
|
|
|
|
|
SHGetDesktopFolder(&psfdesktop);
|
|
|
|
|
|
|
|
/* Test IShellItem */
|
|
|
|
if(pSHCreateShellItem)
|
|
|
|
{
|
|
|
|
IShellItem *shellitem;
|
|
|
|
hres = pSHCreateShellItem(NULL, NULL, pidl_desktop, &shellitem);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
{
|
|
|
|
hres = pSHGetIDListFromObject((IUnknown*)shellitem, &pidl);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
{
|
|
|
|
ok(ILIsEqual(pidl_desktop, pidl), "pidl not equal.\n");
|
|
|
|
pILFree(pidl);
|
|
|
|
}
|
|
|
|
IShellItem_Release(shellitem);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
skip("no SHCreateShellItem.\n");
|
|
|
|
|
|
|
|
/* Test IShellFolder */
|
|
|
|
hres = pSHGetIDListFromObject((IUnknown*)psfdesktop, &pidl);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
{
|
|
|
|
ok(ILIsEqual(pidl_desktop, pidl), "pidl not equal.\n");
|
|
|
|
pILFree(pidl);
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = IShellFolder_CreateViewObject(psfdesktop, NULL, &IID_IShellView, (void**)&psv);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
{
|
|
|
|
IEnumIDList *peidl;
|
|
|
|
IDataObject *pdo;
|
|
|
|
SHCONTF enum_flags;
|
|
|
|
|
|
|
|
/* Test IFolderView */
|
|
|
|
hres = pSHGetIDListFromObject((IUnknown*)psv, &pidl);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
{
|
|
|
|
ok(ILIsEqual(pidl_desktop, pidl), "pidl not equal.\n");
|
|
|
|
pILFree(pidl);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Test IDataObject */
|
|
|
|
enum_flags = SHCONTF_NONFOLDERS | SHCONTF_FOLDERS | SHCONTF_INCLUDEHIDDEN;
|
|
|
|
hres = IShellFolder_EnumObjects(psfdesktop, NULL, enum_flags, &peidl);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
{
|
|
|
|
LPITEMIDLIST apidl[5];
|
|
|
|
UINT count = 0;
|
|
|
|
for(count = 0; count < 5; count++)
|
|
|
|
if(IEnumIDList_Next(peidl, 1, &apidl[count], NULL) != S_OK)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if(count)
|
|
|
|
{
|
|
|
|
hres = IShellFolder_GetUIObjectOf(psfdesktop, NULL, 1, (LPCITEMIDLIST*)apidl,
|
|
|
|
&IID_IDataObject, NULL, (void**)&pdo);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
{
|
|
|
|
pidl = (void*)0xDEADBEEF;
|
|
|
|
hres = pSHGetIDListFromObject((IUnknown*)pdo, &pidl);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
ok(pidl != NULL, "pidl is NULL.\n");
|
|
|
|
ok(ILIsEqual(pidl, apidl[0]), "pidl not equal.\n");
|
|
|
|
pILFree(pidl);
|
|
|
|
|
|
|
|
IDataObject_Release(pdo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
skip("No files found - skipping single-file test.\n");
|
|
|
|
|
|
|
|
if(count > 1)
|
|
|
|
{
|
|
|
|
hres = IShellFolder_GetUIObjectOf(psfdesktop, NULL, count, (LPCITEMIDLIST*)apidl,
|
|
|
|
&IID_IDataObject, NULL, (void**)&pdo);
|
|
|
|
ok(hres == S_OK, "got 0x%08x\n", hres);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
{
|
|
|
|
pidl = (void*)0xDEADBEEF;
|
|
|
|
hres = pSHGetIDListFromObject((IUnknown*)pdo, &pidl);
|
|
|
|
ok(hres == E_NOINTERFACE || hres == E_FAIL /*Vista*/,
|
|
|
|
"got 0x%08x\n", hres);
|
|
|
|
ok(pidl == NULL, "pidl is not NULL.\n");
|
2010-07-22 20:17:05 +02:00
|
|
|
|
|
|
|
IDataObject_Release(pdo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
skip("zero or one file found - skipping multi-file test.\n");
|
|
|
|
|
|
|
|
for(i = 0; i < count; i++)
|
|
|
|
pILFree(apidl[i]);
|
|
|
|
|
|
|
|
IEnumIDList_Release(peidl);
|
|
|
|
}
|
|
|
|
|
|
|
|
IShellView_Release(psv);
|
|
|
|
}
|
|
|
|
|
|
|
|
IShellFolder_Release(psfdesktop);
|
2010-07-22 20:17:06 +02:00
|
|
|
pILFree(pidl_desktop);
|
2010-07-22 20:17:05 +02:00
|
|
|
}
|
|
|
|
|
2010-07-25 19:08:14 +02:00
|
|
|
static void test_SHGetItemFromObject(void)
|
|
|
|
{
|
|
|
|
IUnknownImpl *punkimpl;
|
|
|
|
IShellFolder *psfdesktop;
|
|
|
|
LPITEMIDLIST pidl;
|
|
|
|
IShellItem *psi;
|
|
|
|
IUnknown *punk;
|
|
|
|
HRESULT hres;
|
|
|
|
struct if_count ifaces[] =
|
|
|
|
{ {&IID_IPersistIDList, 0},
|
|
|
|
{&IID_IPersistFolder2, 0},
|
|
|
|
{&IID_IDataObject, 0},
|
|
|
|
{&IID_IParentAndItem, 0},
|
|
|
|
{&IID_IFolderView, 0},
|
|
|
|
{NULL, 0} };
|
|
|
|
|
|
|
|
if(!pSHGetItemFromObject)
|
|
|
|
{
|
|
|
|
skip("No SHGetItemFromObject.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
SHGetDesktopFolder(&psfdesktop);
|
|
|
|
|
|
|
|
if(0)
|
|
|
|
{
|
|
|
|
/* Crashes with Windows 7 */
|
2011-02-10 20:57:20 +01:00
|
|
|
pSHGetItemFromObject((IUnknown*)psfdesktop, &IID_IUnknown, NULL);
|
|
|
|
pSHGetItemFromObject(NULL, &IID_IUnknown, NULL);
|
|
|
|
pSHGetItemFromObject((IUnknown*)psfdesktop, NULL, (void**)&punk);
|
2010-07-25 19:08:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
hres = pSHGetItemFromObject(NULL, &IID_IUnknown, (void**)&punk);
|
|
|
|
ok(hres == E_NOINTERFACE, "Got 0x%08x\n", hres);
|
|
|
|
|
|
|
|
punkimpl = HeapAlloc(GetProcessHeap(), 0, sizeof(IUnknownImpl));
|
2011-04-26 23:45:13 +02:00
|
|
|
punkimpl->IUnknown_iface.lpVtbl = &vt_IUnknown;
|
2010-07-25 19:08:14 +02:00
|
|
|
punkimpl->ifaces = ifaces;
|
|
|
|
punkimpl->unknown = 0;
|
|
|
|
|
|
|
|
/* The same as SHGetIDListFromObject */
|
|
|
|
hres = pSHGetIDListFromObject((IUnknown*)punkimpl, &pidl);
|
|
|
|
ok(hres == E_NOINTERFACE, "Got %x\n", hres);
|
|
|
|
ok(ifaces[0].count, "interface not requested.\n");
|
|
|
|
ok(ifaces[1].count, "interface not requested.\n");
|
|
|
|
ok(ifaces[2].count, "interface not requested.\n");
|
|
|
|
todo_wine
|
|
|
|
ok(ifaces[3].count || broken(!ifaces[3].count /*vista*/),
|
|
|
|
"interface not requested.\n");
|
|
|
|
ok(ifaces[4].count || broken(!ifaces[4].count /*vista*/),
|
|
|
|
"interface not requested.\n");
|
|
|
|
|
|
|
|
ok(!punkimpl->unknown, "Got %d unknown.\n", punkimpl->unknown);
|
|
|
|
HeapFree(GetProcessHeap(), 0, punkimpl);
|
|
|
|
|
|
|
|
/* Test IShellItem */
|
|
|
|
hres = pSHGetItemFromObject((IUnknown*)psfdesktop, &IID_IShellItem, (void**)&psi);
|
|
|
|
ok(hres == S_OK, "Got 0x%08x\n", hres);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
{
|
|
|
|
IShellItem *psi2;
|
|
|
|
hres = pSHGetItemFromObject((IUnknown*)psi, &IID_IShellItem, (void**)&psi2);
|
|
|
|
ok(hres == S_OK, "Got 0x%08x\n", hres);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
{
|
|
|
|
todo_wine
|
|
|
|
ok(psi == psi2, "Different instances (%p != %p).\n", psi, psi2);
|
|
|
|
IShellItem_Release(psi2);
|
|
|
|
}
|
|
|
|
IShellItem_Release(psi);
|
|
|
|
}
|
|
|
|
|
|
|
|
IShellFolder_Release(psfdesktop);
|
|
|
|
}
|
|
|
|
|
2010-07-26 11:54:03 +02:00
|
|
|
static void test_SHCreateShellItemArray(void)
|
|
|
|
{
|
|
|
|
IShellFolder *pdesktopsf, *psf;
|
|
|
|
IShellItemArray *psia;
|
|
|
|
IEnumIDList *peidl;
|
|
|
|
HRESULT hr;
|
|
|
|
WCHAR cTestDirW[MAX_PATH];
|
|
|
|
LPITEMIDLIST pidl_testdir, pidl;
|
|
|
|
static const WCHAR testdirW[] = {'t','e','s','t','d','i','r',0};
|
|
|
|
|
|
|
|
if(!pSHCreateShellItemArray) {
|
|
|
|
skip("No pSHCreateShellItemArray!\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ok(pSHGetSpecialFolderLocation != NULL, "SHGetSpecialFolderLocation missing.\n");
|
|
|
|
|
|
|
|
if(0)
|
|
|
|
{
|
|
|
|
/* Crashes under native */
|
|
|
|
pSHCreateShellItemArray(NULL, NULL, 0, NULL, NULL);
|
|
|
|
pSHCreateShellItemArray(NULL, NULL, 1, NULL, NULL);
|
|
|
|
pSHCreateShellItemArray(NULL, pdesktopsf, 0, NULL, NULL);
|
|
|
|
pSHCreateShellItemArray(pidl, NULL, 0, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = pSHCreateShellItemArray(NULL, NULL, 0, NULL, &psia);
|
|
|
|
ok(hr == E_POINTER, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
SHGetDesktopFolder(&pdesktopsf);
|
|
|
|
hr = pSHCreateShellItemArray(NULL, pdesktopsf, 0, NULL, &psia);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = pSHCreateShellItemArray(NULL, pdesktopsf, 1, NULL, &psia);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
pSHGetSpecialFolderLocation(NULL, CSIDL_DESKTOP, &pidl);
|
|
|
|
hr = pSHCreateShellItemArray(pidl, NULL, 0, NULL, &psia);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
pILFree(pidl);
|
|
|
|
|
|
|
|
GetCurrentDirectoryW(MAX_PATH, cTestDirW);
|
|
|
|
myPathAddBackslashW(cTestDirW);
|
|
|
|
lstrcatW(cTestDirW, testdirW);
|
|
|
|
|
|
|
|
CreateFilesFolders();
|
|
|
|
|
|
|
|
hr = IShellFolder_ParseDisplayName(pdesktopsf, NULL, NULL, cTestDirW, NULL, &pidl_testdir, 0);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = IShellFolder_BindToObject(pdesktopsf, pidl_testdir, NULL, (REFIID)&IID_IShellFolder,
|
|
|
|
(void**)&psf);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
}
|
|
|
|
IShellFolder_Release(pdesktopsf);
|
|
|
|
|
|
|
|
if(FAILED(hr))
|
|
|
|
{
|
|
|
|
skip("Failed to set up environment for SHCreateShellItemArray tests.\n");
|
|
|
|
pILFree(pidl_testdir);
|
|
|
|
Cleanup();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IShellFolder_EnumObjects(psf, NULL, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS, &peidl);
|
|
|
|
ok(hr == S_OK, "Got %08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
LPITEMIDLIST apidl[5];
|
|
|
|
UINT done, numitems, i;
|
|
|
|
|
|
|
|
for(done = 0; done < 5; done++)
|
|
|
|
if(IEnumIDList_Next(peidl, 1, &apidl[done], NULL) != S_OK)
|
|
|
|
break;
|
|
|
|
ok(done == 5, "Got %d pidls\n", done);
|
|
|
|
IEnumIDList_Release(peidl);
|
|
|
|
|
|
|
|
/* Create a ShellItemArray */
|
|
|
|
hr = pSHCreateShellItemArray(NULL, psf, done, (LPCITEMIDLIST*)apidl, &psia);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
IShellItem *psi;
|
|
|
|
|
|
|
|
if(0)
|
|
|
|
{
|
|
|
|
/* Crashes in Windows 7 */
|
2011-02-10 20:57:20 +01:00
|
|
|
IShellItemArray_GetCount(psia, NULL);
|
2010-07-26 11:54:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
IShellItemArray_GetCount(psia, &numitems);
|
|
|
|
ok(numitems == done, "Got %d, expected %d\n", numitems, done);
|
|
|
|
|
|
|
|
hr = IShellItemArray_GetItemAt(psia, numitems, &psi);
|
|
|
|
ok(hr == E_FAIL, "Got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
/* Compare all the items */
|
|
|
|
for(i = 0; i < numitems; i++)
|
|
|
|
{
|
|
|
|
LPITEMIDLIST pidl_abs;
|
|
|
|
pidl_abs = ILCombine(pidl_testdir, apidl[i]);
|
|
|
|
|
|
|
|
hr = IShellItemArray_GetItemAt(psia, i, &psi);
|
|
|
|
ok(hr == S_OK, "(%d) Failed with 0x%08x\n", i, hr);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = pSHGetIDListFromObject((IUnknown*)psi, &pidl);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
ok(ILIsEqual(pidl_abs, pidl), "Pidl not equal.\n");
|
|
|
|
pILFree(pidl);
|
|
|
|
}
|
|
|
|
IShellItem_Release(psi);
|
|
|
|
}
|
|
|
|
pILFree(pidl_abs);
|
|
|
|
}
|
|
|
|
for(i = 0; i < done; i++)
|
|
|
|
pILFree(apidl[i]);
|
|
|
|
IShellItemArray_Release(psia);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-26 11:54:04 +02:00
|
|
|
/* SHCreateShellItemArrayFromShellItem */
|
|
|
|
if(pSHCreateShellItemArrayFromShellItem)
|
|
|
|
{
|
|
|
|
IShellItem *psi;
|
|
|
|
|
|
|
|
if(0)
|
|
|
|
{
|
|
|
|
/* Crashes under Windows 7 */
|
2011-02-10 20:57:20 +01:00
|
|
|
pSHCreateShellItemArrayFromShellItem(NULL, &IID_IShellItemArray, NULL);
|
|
|
|
pSHCreateShellItemArrayFromShellItem(NULL, &IID_IShellItemArray, (void**)&psia);
|
|
|
|
pSHCreateShellItemArrayFromShellItem(psi, &IID_IShellItemArray, NULL);
|
2010-07-26 11:54:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
hr = pSHCreateItemFromIDList(pidl_testdir, &IID_IShellItem, (void**)&psi);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = pSHCreateShellItemArrayFromShellItem(psi, &IID_IShellItemArray, (void**)&psia);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
IShellItem *psi2;
|
|
|
|
UINT count;
|
|
|
|
hr = IShellItemArray_GetCount(psia, &count);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
ok(count == 1, "Got count %d\n", count);
|
|
|
|
hr = IShellItemArray_GetItemAt(psia, 0, &psi2);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
todo_wine
|
|
|
|
ok(psi != psi2, "ShellItems are of the same instance.\n");
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
LPITEMIDLIST pidl1, pidl2;
|
|
|
|
hr = pSHGetIDListFromObject((IUnknown*)psi, &pidl1);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
ok(pidl1 != NULL, "pidl1 was null.\n");
|
|
|
|
hr = pSHGetIDListFromObject((IUnknown*)psi2, &pidl2);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
ok(pidl2 != NULL, "pidl2 was null.\n");
|
|
|
|
ok(ILIsEqual(pidl1, pidl2), "pidls not equal.\n");
|
|
|
|
pILFree(pidl1);
|
|
|
|
pILFree(pidl2);
|
|
|
|
IShellItem_Release(psi2);
|
|
|
|
}
|
|
|
|
hr = IShellItemArray_GetItemAt(psia, 1, &psi2);
|
|
|
|
ok(hr == E_FAIL, "Got 0x%08x\n", hr);
|
|
|
|
IShellItemArray_Release(psia);
|
|
|
|
}
|
|
|
|
IShellItem_Release(psi);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
skip("No SHCreateShellItemArrayFromShellItem.\n");
|
|
|
|
|
2010-07-26 11:54:05 +02:00
|
|
|
if(pSHCreateShellItemArrayFromDataObject)
|
|
|
|
{
|
|
|
|
IShellView *psv;
|
|
|
|
|
|
|
|
if(0)
|
|
|
|
{
|
|
|
|
/* Crashes under Windows 7 */
|
2011-02-10 20:57:20 +01:00
|
|
|
pSHCreateShellItemArrayFromDataObject(NULL, &IID_IShellItemArray, NULL);
|
2010-07-26 11:54:05 +02:00
|
|
|
}
|
|
|
|
hr = pSHCreateShellItemArrayFromDataObject(NULL, &IID_IShellItemArray, (void**)&psia);
|
|
|
|
ok(hr == E_INVALIDARG, "Got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IShellFolder_CreateViewObject(psf, NULL, &IID_IShellView, (void**)&psv);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
IEnumIDList *peidl;
|
|
|
|
IDataObject *pdo;
|
|
|
|
SHCONTF enum_flags;
|
|
|
|
|
|
|
|
enum_flags = SHCONTF_NONFOLDERS | SHCONTF_FOLDERS | SHCONTF_INCLUDEHIDDEN;
|
|
|
|
hr = IShellFolder_EnumObjects(psf, NULL, enum_flags, &peidl);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
LPITEMIDLIST apidl[5];
|
|
|
|
UINT count, i;
|
|
|
|
|
|
|
|
for(count = 0; count < 5; count++)
|
|
|
|
if(IEnumIDList_Next(peidl, 1, &apidl[count], NULL) != S_OK)
|
|
|
|
break;
|
|
|
|
ok(count == 5, "Got %d\n", count);
|
|
|
|
|
|
|
|
if(count)
|
|
|
|
{
|
|
|
|
hr = IShellFolder_GetUIObjectOf(psf, NULL, count, (LPCITEMIDLIST*)apidl,
|
|
|
|
&IID_IDataObject, NULL, (void**)&pdo);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = pSHCreateShellItemArrayFromDataObject(pdo, &IID_IShellItemArray,
|
|
|
|
(void**)&psia);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
UINT count_sia, i;
|
|
|
|
hr = IShellItemArray_GetCount(psia, &count_sia);
|
2011-02-10 20:58:08 +01:00
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
2010-07-26 11:54:05 +02:00
|
|
|
ok(count_sia == count, "Counts differ (%d, %d)\n", count, count_sia);
|
|
|
|
for(i = 0; i < count_sia; i++)
|
|
|
|
{
|
|
|
|
LPITEMIDLIST pidl_abs = ILCombine(pidl_testdir, apidl[i]);
|
|
|
|
IShellItem *psi;
|
|
|
|
hr = IShellItemArray_GetItemAt(psia, i, &psi);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
LPITEMIDLIST pidl;
|
|
|
|
hr = pSHGetIDListFromObject((IUnknown*)psi, &pidl);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
ok(pidl != NULL, "pidl as NULL.\n");
|
|
|
|
ok(ILIsEqual(pidl, pidl_abs), "pidls differ.\n");
|
|
|
|
pILFree(pidl);
|
|
|
|
IShellItem_Release(psi);
|
|
|
|
}
|
|
|
|
pILFree(pidl_abs);
|
|
|
|
}
|
|
|
|
|
|
|
|
IShellItemArray_Release(psia);
|
|
|
|
}
|
|
|
|
|
|
|
|
IDataObject_Release(pdo);
|
|
|
|
}
|
|
|
|
for(i = 0; i < count; i++)
|
|
|
|
pILFree(apidl[i]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
skip("No files found - skipping test.\n");
|
|
|
|
|
|
|
|
IEnumIDList_Release(peidl);
|
|
|
|
}
|
|
|
|
IShellView_Release(psv);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
skip("No SHCreateShellItemArrayFromDataObject.\n");
|
2010-07-26 11:54:04 +02:00
|
|
|
|
2010-07-26 11:54:03 +02:00
|
|
|
IShellFolder_Release(psf);
|
|
|
|
pILFree(pidl_testdir);
|
|
|
|
Cleanup();
|
|
|
|
}
|
|
|
|
|
2010-08-16 09:17:30 +02:00
|
|
|
static void test_ShellItemBindToHandler(void)
|
|
|
|
{
|
|
|
|
IShellItem *psi;
|
|
|
|
LPITEMIDLIST pidl_desktop;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if(!pSHCreateShellItem)
|
|
|
|
{
|
|
|
|
skip("SHCreateShellItem missing.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = pSHGetSpecialFolderLocation(NULL, CSIDL_DESKTOP, &pidl_desktop);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = pSHCreateShellItem(NULL, NULL, pidl_desktop, &psi);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
}
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
IPersistFolder2 *ppf2;
|
|
|
|
IUnknown *punk;
|
|
|
|
|
|
|
|
if(0)
|
|
|
|
{
|
|
|
|
/* Crashes under Windows 7 */
|
2011-02-10 20:57:20 +01:00
|
|
|
IShellItem_BindToHandler(psi, NULL, NULL, NULL, NULL);
|
|
|
|
IShellItem_BindToHandler(psi, NULL, &IID_IUnknown, &IID_IUnknown, NULL);
|
2010-08-16 09:17:30 +02:00
|
|
|
}
|
|
|
|
hr = IShellItem_BindToHandler(psi, NULL, &IID_IUnknown, &IID_IUnknown, (void**)&punk);
|
|
|
|
ok(hr == MK_E_NOOBJECT, "Got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
/* BHID_SFObject */
|
|
|
|
hr = IShellItem_BindToHandler(psi, NULL, &BHID_SFObject, &IID_IShellFolder, (void**)&punk);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr)) IUnknown_Release(punk);
|
|
|
|
hr = IShellItem_BindToHandler(psi, NULL, &BHID_SFObject, &IID_IPersistFolder2, (void**)&ppf2);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
LPITEMIDLIST pidl_tmp;
|
|
|
|
hr = IPersistFolder2_GetCurFolder(ppf2, &pidl_tmp);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
ok(ILIsEqual(pidl_desktop, pidl_tmp), "Pidl not equal (%p, %p)\n", pidl_desktop, pidl_tmp);
|
|
|
|
pILFree(pidl_tmp);
|
|
|
|
}
|
|
|
|
IPersistFolder2_Release(ppf2);
|
|
|
|
}
|
|
|
|
|
2010-08-24 10:56:20 +02:00
|
|
|
/* BHID_SFUIObject */
|
|
|
|
hr = IShellItem_BindToHandler(psi, NULL, &BHID_SFUIObject, &IID_IDataObject, (void**)&punk);
|
|
|
|
ok(hr == S_OK || broken(hr == E_NOINTERFACE /* XP */), "Got 0x%08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr)) IUnknown_Release(punk);
|
|
|
|
hr = IShellItem_BindToHandler(psi, NULL, &BHID_SFUIObject, &IID_IContextMenu, (void**)&punk);
|
|
|
|
ok(hr == S_OK || broken(hr == E_NOINTERFACE /* XP */), "Got 0x%08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr)) IUnknown_Release(punk);
|
|
|
|
|
|
|
|
/* BHID_DataObject */
|
|
|
|
hr = IShellItem_BindToHandler(psi, NULL, &BHID_DataObject, &IID_IDataObject, (void**)&punk);
|
|
|
|
ok(hr == S_OK || broken(hr == MK_E_NOOBJECT /* XP */), "Got 0x%08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr)) IUnknown_Release(punk);
|
|
|
|
|
2010-08-16 09:17:30 +02:00
|
|
|
todo_wine
|
|
|
|
{
|
|
|
|
/* BHID_SFViewObject */
|
|
|
|
hr = IShellItem_BindToHandler(psi, NULL, &BHID_SFViewObject, &IID_IShellView, (void**)&punk);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr)) IUnknown_Release(punk);
|
|
|
|
hr = IShellItem_BindToHandler(psi, NULL, &BHID_SFViewObject, &IID_IShellFolderView, (void**)&punk);
|
|
|
|
ok(hr == E_NOINTERFACE, "Got 0x%08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr)) IUnknown_Release(punk);
|
|
|
|
|
|
|
|
/* BHID_Storage */
|
|
|
|
hr = IShellItem_BindToHandler(psi, NULL, &BHID_Storage, &IID_IStream, (void**)&punk);
|
|
|
|
ok(hr == E_NOINTERFACE, "Got 0x%08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr)) IUnknown_Release(punk);
|
|
|
|
hr = IShellItem_BindToHandler(psi, NULL, &BHID_Storage, &IID_IUnknown, (void**)&punk);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr)) IUnknown_Release(punk);
|
|
|
|
|
|
|
|
/* BHID_Stream */
|
|
|
|
hr = IShellItem_BindToHandler(psi, NULL, &BHID_Stream, &IID_IStream, (void**)&punk);
|
|
|
|
ok(hr == E_NOINTERFACE, "Got 0x%08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr)) IUnknown_Release(punk);
|
|
|
|
hr = IShellItem_BindToHandler(psi, NULL, &BHID_Stream, &IID_IUnknown, (void**)&punk);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr)) IUnknown_Release(punk);
|
|
|
|
|
|
|
|
/* BHID_StorageEnum */
|
|
|
|
hr = IShellItem_BindToHandler(psi, NULL, &BHID_StorageEnum, &IID_IEnumShellItems, (void**)&punk);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr)) IUnknown_Release(punk);
|
|
|
|
|
|
|
|
/* BHID_Transfer */
|
|
|
|
hr = IShellItem_BindToHandler(psi, NULL, &BHID_Transfer, &IID_IUnknown, (void**)&punk);
|
|
|
|
ok(hr == E_NOINTERFACE || broken(hr == MK_E_NOOBJECT /* XP */), "Got 0x%08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr)) IUnknown_Release(punk);
|
|
|
|
|
|
|
|
/* BHID_EnumItems */
|
|
|
|
hr = IShellItem_BindToHandler(psi, NULL, &BHID_EnumItems, &IID_IEnumShellItems, (void**)&punk);
|
|
|
|
ok(hr == S_OK || broken(hr == MK_E_NOOBJECT /* XP */), "Got 0x%08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr)) IUnknown_Release(punk);
|
|
|
|
|
|
|
|
/* BHID_Filter */
|
|
|
|
hr = IShellItem_BindToHandler(psi, NULL, &BHID_Filter, &IID_IUnknown, (void**)&punk);
|
|
|
|
ok(hr == S_OK || broken(hr == MK_E_NOOBJECT /* XP */), "Got 0x%08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr)) IUnknown_Release(punk);
|
|
|
|
|
|
|
|
/* BHID_LinkTargetItem */
|
|
|
|
hr = IShellItem_BindToHandler(psi, NULL, &BHID_LinkTargetItem, &IID_IShellItem, (void**)&punk);
|
|
|
|
ok(hr == E_NOINTERFACE || broken(hr == E_INVALIDARG /* XP */), "Got 0x%08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr)) IUnknown_Release(punk);
|
|
|
|
hr = IShellItem_BindToHandler(psi, NULL, &BHID_LinkTargetItem, &IID_IUnknown, (void**)&punk);
|
|
|
|
ok(hr == E_NOINTERFACE || broken(hr == E_INVALIDARG /* XP */), "Got 0x%08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr)) IUnknown_Release(punk);
|
|
|
|
|
|
|
|
/* BHID_PropertyStore */
|
|
|
|
hr = IShellItem_BindToHandler(psi, NULL, &BHID_PropertyStore, &IID_IPropertyStore, (void**)&punk);
|
|
|
|
ok(hr == E_NOINTERFACE || broken(hr == MK_E_NOOBJECT /* XP */), "Got 0x%08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr)) IUnknown_Release(punk);
|
|
|
|
hr = IShellItem_BindToHandler(psi, NULL, &BHID_PropertyStore, &IID_IPropertyStoreFactory, (void**)&punk);
|
|
|
|
ok(hr == E_NOINTERFACE || broken(hr == MK_E_NOOBJECT /* XP */), "Got 0x%08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr)) IUnknown_Release(punk);
|
|
|
|
|
|
|
|
/* BHID_ThumbnailHandler */
|
|
|
|
hr = IShellItem_BindToHandler(psi, NULL, &BHID_ThumbnailHandler, &IID_IUnknown, (void**)&punk);
|
|
|
|
ok(hr == E_INVALIDARG || broken(hr == MK_E_NOOBJECT /* XP */), "Got 0x%08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr)) IUnknown_Release(punk);
|
|
|
|
|
|
|
|
/* BHID_AssociationArray */
|
|
|
|
hr = IShellItem_BindToHandler(psi, NULL, &BHID_AssociationArray, &IID_IQueryAssociations, (void**)&punk);
|
|
|
|
ok(hr == S_OK || broken(hr == MK_E_NOOBJECT /* XP */), "Got 0x%08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr)) IUnknown_Release(punk);
|
|
|
|
|
|
|
|
/* BHID_EnumAssocHandlers */
|
|
|
|
hr = IShellItem_BindToHandler(psi, NULL, &BHID_EnumAssocHandlers, &IID_IUnknown, (void**)&punk);
|
|
|
|
ok(hr == E_NOINTERFACE || broken(hr == MK_E_NOOBJECT /* XP */), "Got 0x%08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr)) IUnknown_Release(punk);
|
|
|
|
}
|
|
|
|
|
|
|
|
IShellItem_Release(psi);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
skip("Failed to create ShellItem.\n");
|
|
|
|
|
|
|
|
pILFree(pidl_desktop);
|
|
|
|
}
|
|
|
|
|
2011-03-16 08:32:56 +01:00
|
|
|
static void test_ShellItemGetAttributes(void)
|
2010-12-19 23:15:12 +01:00
|
|
|
{
|
|
|
|
IShellItem *psi;
|
|
|
|
LPITEMIDLIST pidl_desktop;
|
|
|
|
SFGAOF sfgao;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if(!pSHCreateShellItem)
|
|
|
|
{
|
|
|
|
skip("SHCreateShellItem missing.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = pSHGetSpecialFolderLocation(NULL, CSIDL_DESKTOP, &pidl_desktop);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = pSHCreateShellItem(NULL, NULL, pidl_desktop, &psi);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
pILFree(pidl_desktop);
|
|
|
|
}
|
|
|
|
if(FAILED(hr))
|
|
|
|
{
|
2011-03-05 11:51:37 +01:00
|
|
|
skip("Skipping tests.\n");
|
2010-12-19 23:15:12 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(0)
|
|
|
|
{
|
|
|
|
/* Crashes on native (Win 7) */
|
2011-02-10 20:57:20 +01:00
|
|
|
IShellItem_GetAttributes(psi, 0, NULL);
|
2010-12-19 23:15:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Test GetAttributes on the desktop folder. */
|
|
|
|
sfgao = 0xdeadbeef;
|
|
|
|
hr = IShellItem_GetAttributes(psi, SFGAO_FOLDER, &sfgao);
|
|
|
|
ok(hr == S_OK || broken(hr == E_FAIL) /* <Vista */, "Got 0x%08x\n", hr);
|
|
|
|
ok(sfgao == SFGAO_FOLDER || broken(sfgao == 0) /* <Vista */, "Got 0x%08x\n", sfgao);
|
|
|
|
|
|
|
|
IShellItem_Release(psi);
|
|
|
|
}
|
|
|
|
|
2010-03-03 02:56:20 +01:00
|
|
|
static void test_SHParseDisplayName(void)
|
|
|
|
{
|
|
|
|
LPITEMIDLIST pidl1, pidl2;
|
|
|
|
IShellFolder *desktop;
|
|
|
|
WCHAR dirW[MAX_PATH];
|
|
|
|
WCHAR nameW[10];
|
|
|
|
HRESULT hr;
|
2011-07-29 01:29:39 +02:00
|
|
|
BOOL ret, is_wow64;
|
2010-03-03 02:56:20 +01:00
|
|
|
|
|
|
|
if (!pSHParseDisplayName)
|
|
|
|
{
|
|
|
|
win_skip("SHParseDisplayName isn't available\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (0)
|
|
|
|
{
|
|
|
|
/* crashes on native */
|
2011-02-10 20:57:20 +01:00
|
|
|
pSHParseDisplayName(NULL, NULL, NULL, 0, NULL);
|
2010-03-03 02:56:20 +01:00
|
|
|
nameW[0] = 0;
|
2011-02-10 20:57:20 +01:00
|
|
|
pSHParseDisplayName(nameW, NULL, NULL, 0, NULL);
|
2010-03-03 02:56:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
pidl1 = (LPITEMIDLIST)0xdeadbeef;
|
|
|
|
hr = pSHParseDisplayName(NULL, NULL, &pidl1, 0, NULL);
|
2010-03-04 12:22:49 +01:00
|
|
|
ok(broken(hr == E_OUTOFMEMORY) /* < Vista */ ||
|
|
|
|
hr == E_INVALIDARG, "failed %08x\n", hr);
|
2010-03-03 02:56:20 +01:00
|
|
|
ok(pidl1 == 0, "expected null ptr, got %p\n", pidl1);
|
|
|
|
|
|
|
|
/* dummy name */
|
|
|
|
nameW[0] = 0;
|
|
|
|
hr = pSHParseDisplayName(nameW, NULL, &pidl1, 0, NULL);
|
|
|
|
ok(hr == S_OK, "failed %08x\n", hr);
|
|
|
|
hr = SHGetDesktopFolder(&desktop);
|
|
|
|
ok(hr == S_OK, "failed %08x\n", hr);
|
|
|
|
hr = IShellFolder_ParseDisplayName(desktop, NULL, NULL, nameW, NULL, &pidl2, NULL);
|
|
|
|
ok(hr == S_OK, "failed %08x\n", hr);
|
|
|
|
ret = pILIsEqual(pidl1, pidl2);
|
|
|
|
ok(ret == TRUE, "expected equal idls\n");
|
|
|
|
pILFree(pidl1);
|
|
|
|
pILFree(pidl2);
|
|
|
|
|
|
|
|
/* with path */
|
2010-06-21 11:50:15 +02:00
|
|
|
GetWindowsDirectoryW( dirW, MAX_PATH );
|
2010-03-03 02:56:20 +01:00
|
|
|
|
|
|
|
hr = pSHParseDisplayName(dirW, NULL, &pidl1, 0, NULL);
|
|
|
|
ok(hr == S_OK, "failed %08x\n", hr);
|
|
|
|
hr = IShellFolder_ParseDisplayName(desktop, NULL, NULL, dirW, NULL, &pidl2, NULL);
|
|
|
|
ok(hr == S_OK, "failed %08x\n", hr);
|
|
|
|
|
|
|
|
ret = pILIsEqual(pidl1, pidl2);
|
|
|
|
ok(ret == TRUE, "expected equal idls\n");
|
|
|
|
pILFree(pidl1);
|
|
|
|
pILFree(pidl2);
|
|
|
|
|
2011-07-29 01:29:39 +02:00
|
|
|
/* system32 is not redirected to syswow64 on WOW64 */
|
|
|
|
if (!pIsWow64Process || !pIsWow64Process( GetCurrentProcess(), &is_wow64 )) is_wow64 = FALSE;
|
|
|
|
if (is_wow64 && pGetSystemWow64DirectoryW)
|
|
|
|
{
|
2011-09-25 20:30:42 +02:00
|
|
|
UINT len;
|
2011-07-29 01:29:39 +02:00
|
|
|
*dirW = 0;
|
2011-09-25 20:30:42 +02:00
|
|
|
len = GetSystemDirectoryW(dirW, MAX_PATH);
|
|
|
|
ok(len > 0, "GetSystemDirectoryW failed: %u\n", GetLastError());
|
2011-07-29 01:29:39 +02:00
|
|
|
hr = pSHParseDisplayName(dirW, NULL, &pidl1, 0, NULL);
|
|
|
|
ok(hr == S_OK, "failed %08x\n", hr);
|
|
|
|
*dirW = 0;
|
2011-09-25 20:30:42 +02:00
|
|
|
len = pGetSystemWow64DirectoryW(dirW, MAX_PATH);
|
|
|
|
ok(len > 0, "GetSystemWow64DirectoryW failed: %u\n", GetLastError());
|
2011-07-29 01:29:39 +02:00
|
|
|
hr = pSHParseDisplayName(dirW, NULL, &pidl2, 0, NULL);
|
|
|
|
ok(hr == S_OK, "failed %08x\n", hr);
|
|
|
|
ret = pILIsEqual(pidl1, pidl2);
|
|
|
|
ok(ret == FALSE, "expected different idls\n");
|
|
|
|
pILFree(pidl1);
|
|
|
|
pILFree(pidl2);
|
|
|
|
}
|
|
|
|
|
2010-03-03 02:56:20 +01:00
|
|
|
IShellFolder_Release(desktop);
|
|
|
|
}
|
|
|
|
|
2010-03-21 16:44:44 +01:00
|
|
|
static void test_desktop_IPersist(void)
|
|
|
|
{
|
|
|
|
IShellFolder *desktop;
|
|
|
|
IPersist *persist;
|
2010-07-18 14:34:56 +02:00
|
|
|
IPersistFolder2 *ppf2;
|
2010-03-21 16:44:44 +01:00
|
|
|
CLSID clsid;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = SHGetDesktopFolder(&desktop);
|
|
|
|
ok(hr == S_OK, "failed %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IShellFolder_QueryInterface(desktop, &IID_IPersist, (void**)&persist);
|
|
|
|
ok(hr == S_OK || broken(hr == E_NOINTERFACE) /* NT4, W9X */, "failed %08x\n", hr);
|
|
|
|
|
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
|
|
|
if (0)
|
|
|
|
{
|
|
|
|
/* crashes on native */
|
2011-02-10 20:57:20 +01:00
|
|
|
IPersist_GetClassID(persist, NULL);
|
2010-03-21 16:44:44 +01:00
|
|
|
}
|
|
|
|
memset(&clsid, 0, sizeof(clsid));
|
|
|
|
hr = IPersist_GetClassID(persist, &clsid);
|
|
|
|
ok(hr == S_OK, "failed %08x\n", hr);
|
|
|
|
ok(IsEqualIID(&CLSID_ShellDesktop, &clsid), "Expected CLSID_ShellDesktop\n");
|
|
|
|
IPersist_Release(persist);
|
|
|
|
}
|
|
|
|
|
2010-07-18 14:34:56 +02:00
|
|
|
hr = IShellFolder_QueryInterface(desktop, &IID_IPersistFolder2, (void**)&ppf2);
|
|
|
|
ok(hr == S_OK || broken(hr == E_NOINTERFACE) /* pre-Vista */, "failed %08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
IPersistFolder *ppf;
|
|
|
|
LPITEMIDLIST pidl;
|
|
|
|
hr = IShellFolder_QueryInterface(desktop, &IID_IPersistFolder, (void**)&ppf);
|
|
|
|
ok(hr == S_OK, "IID_IPersistFolder2 without IID_IPersistFolder.\n");
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
IPersistFolder_Release(ppf);
|
|
|
|
|
|
|
|
todo_wine {
|
|
|
|
hr = IPersistFolder2_Initialize(ppf2, NULL);
|
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
|
|
|
}
|
|
|
|
|
|
|
|
pidl = NULL;
|
|
|
|
hr = IPersistFolder2_GetCurFolder(ppf2, &pidl);
|
|
|
|
ok(hr == S_OK, "got %08x\n", hr);
|
|
|
|
ok(pidl != NULL, "pidl was NULL.\n");
|
|
|
|
if(SUCCEEDED(hr)) pILFree(pidl);
|
|
|
|
|
|
|
|
IPersistFolder2_Release(ppf2);
|
|
|
|
}
|
|
|
|
|
2010-03-21 16:44:44 +01:00
|
|
|
IShellFolder_Release(desktop);
|
|
|
|
}
|
|
|
|
|
2010-07-17 17:08:18 +02:00
|
|
|
static void test_GetUIObject(void)
|
|
|
|
{
|
|
|
|
IShellFolder *psf_desktop;
|
|
|
|
IContextMenu *pcm;
|
|
|
|
LPITEMIDLIST pidl;
|
|
|
|
HRESULT hr;
|
|
|
|
WCHAR path[MAX_PATH];
|
|
|
|
const WCHAR filename[] =
|
|
|
|
{'\\','t','e','s','t','d','i','r','\\','t','e','s','t','1','.','t','x','t',0};
|
|
|
|
|
|
|
|
if(!pSHBindToParent)
|
|
|
|
{
|
|
|
|
win_skip("SHBindToParent missing.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
GetCurrentDirectoryW(MAX_PATH, path);
|
|
|
|
if(!lstrlenW(path))
|
|
|
|
{
|
|
|
|
skip("GetCurrentDirectoryW returned an empty string.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
lstrcatW(path, filename);
|
|
|
|
SHGetDesktopFolder(&psf_desktop);
|
|
|
|
|
|
|
|
CreateFilesFolders();
|
|
|
|
|
|
|
|
hr = IShellFolder_ParseDisplayName(psf_desktop, NULL, NULL, path, NULL, &pidl, 0);
|
2010-08-03 15:50:47 +02:00
|
|
|
ok(hr == S_OK || broken(hr == E_FAIL) /* WinME */, "Got 0x%08x\n", hr);
|
2010-07-17 17:08:18 +02:00
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
IShellFolder *psf;
|
|
|
|
LPCITEMIDLIST pidl_child;
|
|
|
|
hr = pSHBindToParent(pidl, &IID_IShellFolder, (void**)&psf, &pidl_child);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
2011-09-21 11:59:19 +02:00
|
|
|
hr = IShellFolder_GetUIObjectOf(psf, NULL, 1, &pidl_child, &IID_IContextMenu, NULL,
|
|
|
|
(void**)&pcm);
|
2010-07-17 17:08:18 +02:00
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
HMENU hmenu = CreatePopupMenu();
|
|
|
|
INT max_id, max_id_check;
|
|
|
|
UINT count, i;
|
|
|
|
const int id_upper_limit = 32767;
|
|
|
|
hr = IContextMenu_QueryContextMenu(pcm, hmenu, 0, 0, id_upper_limit, CMF_NORMAL);
|
|
|
|
ok(SUCCEEDED(hr), "Got 0x%08x\n", hr);
|
|
|
|
max_id = HRESULT_CODE(hr) - 1; /* returns max_id + 1 */
|
|
|
|
ok(max_id <= id_upper_limit, "Got %d\n", max_id);
|
|
|
|
count = GetMenuItemCount(hmenu);
|
|
|
|
ok(count, "Got %d\n", count);
|
|
|
|
|
|
|
|
max_id_check = 0;
|
|
|
|
for(i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
MENUITEMINFOA mii;
|
|
|
|
INT res;
|
|
|
|
ZeroMemory(&mii, sizeof(MENUITEMINFOA));
|
|
|
|
mii.cbSize = sizeof(MENUITEMINFOA);
|
|
|
|
mii.fMask = MIIM_ID | MIIM_FTYPE;
|
|
|
|
|
|
|
|
SetLastError(0);
|
|
|
|
res = GetMenuItemInfoA(hmenu, i, TRUE, &mii);
|
|
|
|
ok(res, "Failed (last error: %d).\n", GetLastError());
|
|
|
|
|
|
|
|
ok( (mii.wID <= id_upper_limit) || (mii.fType & MFT_SEPARATOR),
|
2010-08-24 10:04:07 +02:00
|
|
|
"Got non-separator ID out of range: %d (type: %x)\n", mii.wID, mii.fType);
|
2010-07-17 17:08:18 +02:00
|
|
|
if(!(mii.fType & MFT_SEPARATOR))
|
|
|
|
max_id_check = (mii.wID>max_id_check)?mii.wID:max_id_check;
|
|
|
|
}
|
|
|
|
ok((max_id_check == max_id) ||
|
|
|
|
(max_id_check == max_id-1 /* Win 7 */),
|
|
|
|
"Not equal (or near equal), got %d and %d\n", max_id_check, max_id);
|
|
|
|
|
|
|
|
#define is_win2k() (pSHGetFolderPathA && !pSHGetFolderPathAndSubDirA)
|
|
|
|
|
|
|
|
if(count && !is_win2k()) /* Test is interactive on w2k, so skip */
|
|
|
|
{
|
|
|
|
CMINVOKECOMMANDINFO cmi;
|
|
|
|
ZeroMemory(&cmi, sizeof(CMINVOKECOMMANDINFO));
|
|
|
|
cmi.cbSize = sizeof(CMINVOKECOMMANDINFO);
|
|
|
|
|
2010-08-24 09:53:35 +02:00
|
|
|
/* Attempt to execute a nonexistent command */
|
2010-07-17 17:08:18 +02:00
|
|
|
cmi.lpVerb = MAKEINTRESOURCEA(9999);
|
|
|
|
hr = IContextMenu_InvokeCommand(pcm, &cmi);
|
|
|
|
ok(hr == E_INVALIDARG, "Got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
cmi.lpVerb = "foobar_wine_test";
|
|
|
|
hr = IContextMenu_InvokeCommand(pcm, &cmi);
|
|
|
|
ok( (hr == E_INVALIDARG) || (hr == E_FAIL /* Win7 */) ||
|
|
|
|
(hr == HRESULT_FROM_WIN32(ERROR_NO_ASSOCIATION) /* Vista */),
|
|
|
|
"Got 0x%08x\n", hr);
|
|
|
|
}
|
|
|
|
#undef is_win2k
|
|
|
|
|
|
|
|
DestroyMenu(hmenu);
|
|
|
|
IContextMenu_Release(pcm);
|
|
|
|
}
|
|
|
|
IShellFolder_Release(psf);
|
|
|
|
}
|
|
|
|
if(pILFree) pILFree(pidl);
|
|
|
|
}
|
|
|
|
|
|
|
|
IShellFolder_Release(psf_desktop);
|
|
|
|
Cleanup();
|
|
|
|
}
|
|
|
|
|
2010-07-21 21:04:22 +02:00
|
|
|
#define verify_pidl(i,p) r_verify_pidl(__LINE__, i, p)
|
|
|
|
static void r_verify_pidl(unsigned l, LPCITEMIDLIST pidl, const WCHAR *path)
|
|
|
|
{
|
|
|
|
LPCITEMIDLIST child;
|
|
|
|
IShellFolder *parent;
|
|
|
|
STRRET filename;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if(!pSHBindToParent){
|
|
|
|
win_skip("SHBindToParent is not available, not performing full PIDL verification\n");
|
|
|
|
if(path)
|
|
|
|
ok_(__FILE__,l)(pidl != NULL, "Expected PIDL to be non-NULL\n");
|
|
|
|
else
|
|
|
|
ok_(__FILE__,l)(pidl == NULL, "Expected PIDL to be NULL\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(path){
|
|
|
|
if(!pidl){
|
|
|
|
ok_(__FILE__,l)(0, "didn't get expected path (%s), instead: NULL\n", wine_dbgstr_w(path));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = pSHBindToParent(pidl, &IID_IShellFolder, (LPVOID*)&parent, &child);
|
|
|
|
ok_(__FILE__,l)(hr == S_OK, "SHBindToParent failed: 0x%08x\n", hr);
|
|
|
|
if(FAILED(hr))
|
|
|
|
return;
|
|
|
|
|
|
|
|
hr = IShellFolder_GetDisplayNameOf(parent, child, SHGDN_FORPARSING, &filename);
|
|
|
|
ok_(__FILE__,l)(hr == S_OK, "GetDisplayNameOf failed: 0x%08x\n", hr);
|
|
|
|
if(FAILED(hr)){
|
|
|
|
IShellFolder_Release(parent);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-08-03 15:50:47 +02:00
|
|
|
ok_(__FILE__,l)(filename.uType == STRRET_WSTR || filename.uType == STRRET_CSTR,
|
|
|
|
"Got unexpected string type: %d\n", filename.uType);
|
|
|
|
if(filename.uType == STRRET_WSTR){
|
2010-08-29 23:39:55 +02:00
|
|
|
ok_(__FILE__,l)(lstrcmpW(path, U(filename).pOleStr) == 0,
|
2010-08-03 15:50:47 +02:00
|
|
|
"didn't get expected path (%s), instead: %s\n",
|
2010-08-29 23:39:55 +02:00
|
|
|
wine_dbgstr_w(path), wine_dbgstr_w(U(filename).pOleStr));
|
2011-01-15 19:29:08 +01:00
|
|
|
SHFree(U(filename).pOleStr);
|
2010-08-03 15:50:47 +02:00
|
|
|
}else if(filename.uType == STRRET_CSTR){
|
2010-08-29 23:39:55 +02:00
|
|
|
ok_(__FILE__,l)(strcmp_wa(path, U(filename).cStr) == 0,
|
2010-08-03 15:50:47 +02:00
|
|
|
"didn't get expected path (%s), instead: %s\n",
|
2010-08-29 23:39:55 +02:00
|
|
|
wine_dbgstr_w(path), U(filename).cStr);
|
2010-08-03 15:50:47 +02:00
|
|
|
}
|
2010-07-21 21:04:22 +02:00
|
|
|
|
|
|
|
IShellFolder_Release(parent);
|
|
|
|
}else
|
|
|
|
ok_(__FILE__,l)(pidl == NULL, "Expected PIDL to be NULL\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_SHSimpleIDListFromPath(void)
|
|
|
|
{
|
|
|
|
const WCHAR adirW[] = {'C',':','\\','s','i','d','l','f','p','d','i','r',0};
|
|
|
|
const CHAR adirA[] = "C:\\sidlfpdir";
|
|
|
|
BOOL br, is_unicode = !(GetVersion() & 0x80000000);
|
|
|
|
|
|
|
|
LPITEMIDLIST pidl = NULL;
|
|
|
|
|
|
|
|
if(!pSHSimpleIDListFromPathAW){
|
|
|
|
win_skip("SHSimpleIDListFromPathAW not available\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
br = CreateDirectoryA(adirA, NULL);
|
|
|
|
ok(br == TRUE, "CreateDirectory failed: %d\n", GetLastError());
|
|
|
|
|
|
|
|
if(is_unicode)
|
|
|
|
pidl = pSHSimpleIDListFromPathAW(adirW);
|
|
|
|
else
|
|
|
|
pidl = pSHSimpleIDListFromPathAW(adirA);
|
|
|
|
verify_pidl(pidl, adirW);
|
|
|
|
pILFree(pidl);
|
|
|
|
|
|
|
|
br = RemoveDirectoryA(adirA);
|
|
|
|
ok(br == TRUE, "RemoveDirectory failed: %d\n", GetLastError());
|
|
|
|
|
|
|
|
if(is_unicode)
|
|
|
|
pidl = pSHSimpleIDListFromPathAW(adirW);
|
|
|
|
else
|
|
|
|
pidl = pSHSimpleIDListFromPathAW(adirA);
|
|
|
|
verify_pidl(pidl, adirW);
|
|
|
|
pILFree(pidl);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* IFileSystemBindData impl */
|
|
|
|
static HRESULT WINAPI fsbd_QueryInterface(IFileSystemBindData *fsbd,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
if(IsEqualIID(riid, &IID_IFileSystemBindData) ||
|
|
|
|
IsEqualIID(riid, &IID_IUnknown)){
|
|
|
|
*ppv = fsbd;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI fsbd_AddRef(IFileSystemBindData *fsbd)
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI fsbd_Release(IFileSystemBindData *fsbd)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI fsbd_SetFindData(IFileSystemBindData *fsbd,
|
|
|
|
const WIN32_FIND_DATAW *pfd)
|
|
|
|
{
|
|
|
|
ok(0, "SetFindData called\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI fsbd_GetFindData_nul(IFileSystemBindData *fsbd,
|
|
|
|
WIN32_FIND_DATAW *pfd)
|
|
|
|
{
|
|
|
|
memset(pfd, 0, sizeof(WIN32_FIND_DATAW));
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI fsbd_GetFindData_junk(IFileSystemBindData *fsbd,
|
|
|
|
WIN32_FIND_DATAW *pfd)
|
|
|
|
{
|
2011-03-15 02:07:45 +01:00
|
|
|
memset(pfd, 0xef, sizeof(WIN32_FIND_DATAW));
|
2010-07-21 21:04:22 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI fsbd_GetFindData_invalid(IFileSystemBindData *fsbd,
|
|
|
|
WIN32_FIND_DATAW *pfd)
|
|
|
|
{
|
|
|
|
memset(pfd, 0, sizeof(WIN32_FIND_DATAW));
|
|
|
|
*pfd->cFileName = 'a';
|
|
|
|
*pfd->cAlternateFileName = 'a';
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI fsbd_GetFindData_valid(IFileSystemBindData *fsbd,
|
|
|
|
WIN32_FIND_DATAW *pfd)
|
|
|
|
{
|
|
|
|
static const WCHAR adirW[] = {'C',':','\\','f','s','b','d','d','i','r',0};
|
|
|
|
HANDLE handle = FindFirstFileW(adirW, pfd);
|
|
|
|
FindClose(handle);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI fsbd_GetFindData_fail(IFileSystemBindData *fsbd,
|
|
|
|
WIN32_FIND_DATAW *pfd)
|
|
|
|
{
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static IFileSystemBindDataVtbl fsbdVtbl = {
|
|
|
|
fsbd_QueryInterface,
|
|
|
|
fsbd_AddRef,
|
|
|
|
fsbd_Release,
|
|
|
|
fsbd_SetFindData,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static IFileSystemBindData fsbd = { &fsbdVtbl };
|
|
|
|
|
|
|
|
static void test_ParseDisplayNamePBC(void)
|
|
|
|
{
|
|
|
|
WCHAR wFileSystemBindData[] =
|
|
|
|
{'F','i','l','e',' ','S','y','s','t','e','m',' ','B','i','n','d',' ','D','a','t','a',0};
|
|
|
|
WCHAR adirW[] = {'C',':','\\','f','s','b','d','d','i','r',0};
|
2010-11-11 22:58:12 +01:00
|
|
|
WCHAR afileW[] = {'C',':','\\','f','s','b','d','d','i','r','\\','f','i','l','e','.','t','x','t',0};
|
2010-11-17 18:56:13 +01:00
|
|
|
WCHAR afile2W[] = {'C',':','\\','f','s','b','d','d','i','r','\\','s','\\','f','i','l','e','.','t','x','t',0};
|
2010-07-21 21:04:22 +02:00
|
|
|
const HRESULT exp_err = HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
|
|
|
|
|
|
|
|
IShellFolder *psf;
|
|
|
|
IBindCtx *pbc;
|
|
|
|
HRESULT hres;
|
|
|
|
ITEMIDLIST *pidl;
|
|
|
|
|
|
|
|
/* Check if we support WCHAR functions */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
lstrcmpiW(adirW, adirW);
|
|
|
|
if(GetLastError() == ERROR_CALL_NOT_IMPLEMENTED){
|
|
|
|
win_skip("Most W-calls are not implemented\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = SHGetDesktopFolder(&psf);
|
|
|
|
ok(hres == S_OK, "SHGetDesktopFolder failed: 0x%08x\n", hres);
|
|
|
|
if(FAILED(hres)){
|
|
|
|
win_skip("Failed to get IShellFolder, can't run tests\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* fails on unknown dir with no IBindCtx */
|
|
|
|
hres = IShellFolder_ParseDisplayName(psf, NULL, NULL, adirW, NULL, &pidl, NULL);
|
2010-11-11 22:58:12 +01:00
|
|
|
ok(hres == exp_err || broken(hres == E_FAIL) /* NT4 */,
|
|
|
|
"ParseDisplayName failed with wrong error: 0x%08x\n", hres);
|
|
|
|
hres = IShellFolder_ParseDisplayName(psf, NULL, NULL, afileW, NULL, &pidl, NULL);
|
2010-11-17 18:56:13 +01:00
|
|
|
ok(hres == exp_err || broken(hres == E_FAIL) /* NT4 */,
|
|
|
|
"ParseDisplayName failed with wrong error: 0x%08x\n", hres);
|
|
|
|
hres = IShellFolder_ParseDisplayName(psf, NULL, NULL, afile2W, NULL, &pidl, NULL);
|
2010-07-21 21:04:22 +02:00
|
|
|
ok(hres == exp_err || broken(hres == E_FAIL) /* NT4 */,
|
|
|
|
"ParseDisplayName failed with wrong error: 0x%08x\n", hres);
|
|
|
|
|
|
|
|
/* fails on unknown dir with IBindCtx with no IFileSystemBindData */
|
|
|
|
hres = CreateBindCtx(0, &pbc);
|
|
|
|
ok(hres == S_OK, "CreateBindCtx failed: 0x%08x\n", hres);
|
|
|
|
|
|
|
|
hres = IShellFolder_ParseDisplayName(psf, NULL, pbc, adirW, NULL, &pidl, NULL);
|
2010-11-11 22:58:12 +01:00
|
|
|
ok(hres == exp_err || broken(hres == E_FAIL) /* NT4 */,
|
|
|
|
"ParseDisplayName failed with wrong error: 0x%08x\n", hres);
|
|
|
|
hres = IShellFolder_ParseDisplayName(psf, NULL, pbc, afileW, NULL, &pidl, NULL);
|
2010-11-17 18:56:13 +01:00
|
|
|
ok(hres == exp_err || broken(hres == E_FAIL) /* NT4 */,
|
|
|
|
"ParseDisplayName failed with wrong error: 0x%08x\n", hres);
|
|
|
|
hres = IShellFolder_ParseDisplayName(psf, NULL, pbc, afile2W, NULL, &pidl, NULL);
|
2010-07-21 21:04:22 +02:00
|
|
|
ok(hres == exp_err || broken(hres == E_FAIL) /* NT4 */,
|
|
|
|
"ParseDisplayName failed with wrong error: 0x%08x\n", hres);
|
|
|
|
|
|
|
|
/* unknown dir with IBindCtx with IFileSystemBindData */
|
|
|
|
hres = IBindCtx_RegisterObjectParam(pbc, wFileSystemBindData, (IUnknown*)&fsbd);
|
|
|
|
ok(hres == S_OK, "RegisterObjectParam failed: 0x%08x\n", hres);
|
|
|
|
|
|
|
|
/* return E_FAIL from GetFindData */
|
|
|
|
pidl = (ITEMIDLIST*)0xdeadbeef;
|
|
|
|
fsbdVtbl.GetFindData = fsbd_GetFindData_fail;
|
|
|
|
hres = IShellFolder_ParseDisplayName(psf, NULL, pbc, adirW, NULL, &pidl, NULL);
|
|
|
|
ok(hres == S_OK || broken(hres == E_FAIL) /* NT4 */,
|
|
|
|
"ParseDisplayName failed: 0x%08x\n", hres);
|
|
|
|
if(SUCCEEDED(hres)){
|
|
|
|
verify_pidl(pidl, adirW);
|
|
|
|
ILFree(pidl);
|
|
|
|
}
|
|
|
|
|
2010-11-11 22:58:12 +01:00
|
|
|
hres = IShellFolder_ParseDisplayName(psf, NULL, pbc, afileW, NULL, &pidl, NULL);
|
|
|
|
ok(hres == S_OK || broken(hres == E_FAIL) /* NT4 */,
|
|
|
|
"ParseDisplayName failed: 0x%08x\n", hres);
|
|
|
|
if(SUCCEEDED(hres)){
|
|
|
|
verify_pidl(pidl, afileW);
|
|
|
|
ILFree(pidl);
|
|
|
|
}
|
|
|
|
|
2010-11-17 18:56:13 +01:00
|
|
|
hres = IShellFolder_ParseDisplayName(psf, NULL, pbc, afile2W, NULL, &pidl, NULL);
|
|
|
|
ok(hres == S_OK || broken(hres == E_FAIL) /* NT4 */,
|
|
|
|
"ParseDisplayName failed: 0x%08x\n", hres);
|
|
|
|
if(SUCCEEDED(hres)){
|
|
|
|
verify_pidl(pidl, afile2W);
|
|
|
|
ILFree(pidl);
|
|
|
|
}
|
|
|
|
|
2010-07-21 21:04:22 +02:00
|
|
|
/* set FIND_DATA struct to NULLs */
|
|
|
|
pidl = (ITEMIDLIST*)0xdeadbeef;
|
|
|
|
fsbdVtbl.GetFindData = fsbd_GetFindData_nul;
|
|
|
|
hres = IShellFolder_ParseDisplayName(psf, NULL, pbc, adirW, NULL, &pidl, NULL);
|
|
|
|
ok(hres == S_OK || broken(hres == E_FAIL) /* NT4 */,
|
|
|
|
"ParseDisplayName failed: 0x%08x\n", hres);
|
|
|
|
if(SUCCEEDED(hres)){
|
|
|
|
verify_pidl(pidl, adirW);
|
|
|
|
ILFree(pidl);
|
|
|
|
}
|
|
|
|
|
2010-11-11 22:58:12 +01:00
|
|
|
hres = IShellFolder_ParseDisplayName(psf, NULL, pbc, afileW, NULL, &pidl, NULL);
|
|
|
|
ok(hres == S_OK || broken(hres == E_FAIL) /* NT4 */,
|
|
|
|
"ParseDisplayName failed: 0x%08x\n", hres);
|
|
|
|
if(SUCCEEDED(hres)){
|
|
|
|
verify_pidl(pidl, afileW);
|
|
|
|
ILFree(pidl);
|
|
|
|
}
|
|
|
|
|
2010-11-17 18:56:13 +01:00
|
|
|
hres = IShellFolder_ParseDisplayName(psf, NULL, pbc, afile2W, NULL, &pidl, NULL);
|
|
|
|
ok(hres == S_OK || broken(hres == E_FAIL) /* NT4 */,
|
|
|
|
"ParseDisplayName failed: 0x%08x\n", hres);
|
|
|
|
if(SUCCEEDED(hres)){
|
|
|
|
verify_pidl(pidl, afile2W);
|
|
|
|
ILFree(pidl);
|
|
|
|
}
|
|
|
|
|
2010-07-21 21:04:22 +02:00
|
|
|
/* set FIND_DATA struct to junk */
|
|
|
|
pidl = (ITEMIDLIST*)0xdeadbeef;
|
|
|
|
fsbdVtbl.GetFindData = fsbd_GetFindData_junk;
|
|
|
|
hres = IShellFolder_ParseDisplayName(psf, NULL, pbc, adirW, NULL, &pidl, NULL);
|
|
|
|
ok(hres == S_OK || broken(hres == E_FAIL) /* NT4 */,
|
|
|
|
"ParseDisplayName failed: 0x%08x\n", hres);
|
|
|
|
if(SUCCEEDED(hres)){
|
|
|
|
verify_pidl(pidl, adirW);
|
|
|
|
ILFree(pidl);
|
|
|
|
}
|
|
|
|
|
2010-11-11 22:58:12 +01:00
|
|
|
hres = IShellFolder_ParseDisplayName(psf, NULL, pbc, afileW, NULL, &pidl, NULL);
|
|
|
|
ok(hres == S_OK || broken(hres == E_FAIL) /* NT4 */,
|
|
|
|
"ParseDisplayName failed: 0x%08x\n", hres);
|
|
|
|
if(SUCCEEDED(hres)){
|
|
|
|
verify_pidl(pidl, afileW);
|
|
|
|
ILFree(pidl);
|
|
|
|
}
|
|
|
|
|
2010-11-17 18:56:13 +01:00
|
|
|
hres = IShellFolder_ParseDisplayName(psf, NULL, pbc, afile2W, NULL, &pidl, NULL);
|
|
|
|
ok(hres == S_OK || broken(hres == E_FAIL) /* NT4 */,
|
|
|
|
"ParseDisplayName failed: 0x%08x\n", hres);
|
|
|
|
if(SUCCEEDED(hres)){
|
|
|
|
verify_pidl(pidl, afile2W);
|
|
|
|
ILFree(pidl);
|
|
|
|
}
|
|
|
|
|
2010-07-21 21:04:22 +02:00
|
|
|
/* set FIND_DATA struct to invalid data */
|
|
|
|
pidl = (ITEMIDLIST*)0xdeadbeef;
|
|
|
|
fsbdVtbl.GetFindData = fsbd_GetFindData_invalid;
|
|
|
|
hres = IShellFolder_ParseDisplayName(psf, NULL, pbc, adirW, NULL, &pidl, NULL);
|
|
|
|
ok(hres == S_OK || broken(hres == E_FAIL) /* NT4 */,
|
|
|
|
"ParseDisplayName failed: 0x%08x\n", hres);
|
|
|
|
if(SUCCEEDED(hres)){
|
|
|
|
verify_pidl(pidl, adirW);
|
|
|
|
ILFree(pidl);
|
|
|
|
}
|
|
|
|
|
2010-11-11 22:58:12 +01:00
|
|
|
hres = IShellFolder_ParseDisplayName(psf, NULL, pbc, afileW, NULL, &pidl, NULL);
|
|
|
|
ok(hres == S_OK || broken(hres == E_FAIL) /* NT4 */,
|
|
|
|
"ParseDisplayName failed: 0x%08x\n", hres);
|
|
|
|
if(SUCCEEDED(hres)){
|
|
|
|
verify_pidl(pidl, afileW);
|
|
|
|
ILFree(pidl);
|
|
|
|
}
|
|
|
|
|
2010-11-17 18:56:13 +01:00
|
|
|
hres = IShellFolder_ParseDisplayName(psf, NULL, pbc, afile2W, NULL, &pidl, NULL);
|
|
|
|
ok(hres == S_OK || broken(hres == E_FAIL) /* NT4 */,
|
|
|
|
"ParseDisplayName failed: 0x%08x\n", hres);
|
|
|
|
if(SUCCEEDED(hres)){
|
|
|
|
verify_pidl(pidl, afile2W);
|
|
|
|
ILFree(pidl);
|
|
|
|
}
|
|
|
|
|
2010-07-21 21:04:22 +02:00
|
|
|
/* set FIND_DATA struct to valid data */
|
|
|
|
pidl = (ITEMIDLIST*)0xdeadbeef;
|
|
|
|
fsbdVtbl.GetFindData = fsbd_GetFindData_valid;
|
|
|
|
hres = IShellFolder_ParseDisplayName(psf, NULL, pbc, adirW, NULL, &pidl, NULL);
|
|
|
|
ok(hres == S_OK || broken(hres == E_FAIL) /* NT4 */,
|
|
|
|
"ParseDisplayName failed: 0x%08x\n", hres);
|
|
|
|
if(SUCCEEDED(hres)){
|
|
|
|
verify_pidl(pidl, adirW);
|
|
|
|
ILFree(pidl);
|
|
|
|
}
|
|
|
|
|
2010-11-11 22:58:12 +01:00
|
|
|
hres = IShellFolder_ParseDisplayName(psf, NULL, pbc, afileW, NULL, &pidl, NULL);
|
|
|
|
ok(hres == S_OK || broken(hres == E_FAIL) /* NT4 */,
|
|
|
|
"ParseDisplayName failed: 0x%08x\n", hres);
|
|
|
|
if(SUCCEEDED(hres)){
|
|
|
|
verify_pidl(pidl, afileW);
|
|
|
|
ILFree(pidl);
|
|
|
|
}
|
|
|
|
|
2010-11-17 18:56:13 +01:00
|
|
|
hres = IShellFolder_ParseDisplayName(psf, NULL, pbc, afile2W, NULL, &pidl, NULL);
|
|
|
|
ok(hres == S_OK || broken(hres == E_FAIL) /* NT4 */,
|
|
|
|
"ParseDisplayName failed: 0x%08x\n", hres);
|
|
|
|
if(SUCCEEDED(hres)){
|
|
|
|
verify_pidl(pidl, afile2W);
|
|
|
|
ILFree(pidl);
|
|
|
|
}
|
|
|
|
|
2010-07-21 21:04:22 +02:00
|
|
|
IBindCtx_Release(pbc);
|
|
|
|
IShellFolder_Release(psf);
|
|
|
|
}
|
|
|
|
|
2010-08-03 21:23:43 +02:00
|
|
|
static const CHAR testwindow_class[] = "testwindow";
|
|
|
|
#define WM_USER_NOTIFY (WM_APP+1)
|
|
|
|
|
2010-11-12 22:32:49 +01:00
|
|
|
struct ChNotifyTest {
|
|
|
|
const char id[256];
|
|
|
|
const UINT notify_count;
|
|
|
|
UINT missing_events;
|
2010-08-03 21:23:43 +02:00
|
|
|
UINT signal;
|
2010-11-12 22:32:49 +01:00
|
|
|
const char path_1[256];
|
|
|
|
const char path_2[256];
|
|
|
|
} chnotify_tests[] = {
|
|
|
|
{"MKDIR", 1, 0, SHCNE_MKDIR, "C:\\shell32_cn_test\\test", ""},
|
2010-11-12 22:32:55 +01:00
|
|
|
{"CREATE", 1, 0, SHCNE_CREATE, "C:\\shell32_cn_test\\test\\file.txt", ""},
|
2010-11-12 22:32:49 +01:00
|
|
|
{"RMDIR", 1, 0, SHCNE_RMDIR, "C:\\shell32_cn_test\\test", ""},
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ChNotifyTest *exp_data;
|
2011-09-21 09:54:16 +02:00
|
|
|
BOOL test_new_delivery_flag;
|
2010-08-03 21:23:43 +02:00
|
|
|
|
|
|
|
static LRESULT CALLBACK testwindow_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
|
|
|
{
|
2011-09-21 09:54:16 +02:00
|
|
|
LONG signal = (LONG)lparam;
|
2010-08-03 21:23:43 +02:00
|
|
|
|
|
|
|
switch(msg){
|
|
|
|
case WM_USER_NOTIFY:
|
2011-09-21 09:54:16 +02:00
|
|
|
if(exp_data->missing_events > 0) {
|
2010-11-12 22:32:49 +01:00
|
|
|
WCHAR *path1, *path2;
|
2011-09-21 09:54:16 +02:00
|
|
|
LPITEMIDLIST *pidls = (LPITEMIDLIST*)wparam;
|
|
|
|
HANDLE hLock = NULL;
|
|
|
|
|
|
|
|
if(test_new_delivery_flag) {
|
|
|
|
hLock = SHChangeNotification_Lock((HANDLE)wparam, lparam, &pidls, &signal);
|
|
|
|
ok(hLock != NULL, "SHChangeNotification_Lock returned NULL\n");
|
|
|
|
}
|
2010-08-03 21:23:43 +02:00
|
|
|
|
2010-11-12 22:32:49 +01:00
|
|
|
ok(exp_data->signal == signal,
|
2010-08-03 21:23:43 +02:00
|
|
|
"%s: expected notification type %x, got: %x\n",
|
2010-11-12 22:32:49 +01:00
|
|
|
exp_data->id, exp_data->signal, signal);
|
2010-08-03 21:23:43 +02:00
|
|
|
|
2010-11-12 22:32:49 +01:00
|
|
|
trace("verifying pidls for: %s\n", exp_data->id);
|
|
|
|
path1 = make_wstr(exp_data->path_1);
|
|
|
|
path2 = make_wstr(exp_data->path_2);
|
|
|
|
verify_pidl(pidls[0], path1);
|
|
|
|
verify_pidl(pidls[1], path2);
|
|
|
|
HeapFree(GetProcessHeap(), 0, path1);
|
|
|
|
HeapFree(GetProcessHeap(), 0, path2);
|
2010-08-03 21:23:43 +02:00
|
|
|
|
2010-11-12 22:32:49 +01:00
|
|
|
exp_data->missing_events--;
|
2011-09-21 09:54:16 +02:00
|
|
|
|
|
|
|
if(test_new_delivery_flag)
|
|
|
|
SHChangeNotification_Unlock(hLock);
|
2010-08-03 21:23:43 +02:00
|
|
|
}else
|
2010-11-12 22:32:49 +01:00
|
|
|
ok(0, "Didn't expect a WM_USER_NOTIFY message (event: %x)\n", signal);
|
2010-08-03 21:23:43 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return DefWindowProc(hwnd, msg, wparam, lparam);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void register_testwindow_class(void)
|
|
|
|
{
|
|
|
|
WNDCLASSEXA cls;
|
|
|
|
ATOM ret;
|
|
|
|
|
|
|
|
ZeroMemory(&cls, sizeof(cls));
|
|
|
|
cls.cbSize = sizeof(cls);
|
|
|
|
cls.style = 0;
|
|
|
|
cls.lpfnWndProc = testwindow_wndproc;
|
|
|
|
cls.hInstance = GetModuleHandleA(NULL);
|
|
|
|
cls.lpszClassName = testwindow_class;
|
|
|
|
|
|
|
|
SetLastError(0);
|
|
|
|
ret = RegisterClassExA(&cls);
|
|
|
|
ok(ret != 0, "RegisterClassExA failed: %d\n", GetLastError());
|
|
|
|
}
|
|
|
|
|
|
|
|
/* SHCNF_FLUSH doesn't seem to work as advertised for SHCNF_PATHA, so we
|
|
|
|
* have to poll repeatedly for the message to appear */
|
|
|
|
static void do_events(void)
|
|
|
|
{
|
|
|
|
int c = 0;
|
2010-11-12 22:32:49 +01:00
|
|
|
while (exp_data->missing_events && (c++ < 10)){
|
2010-08-03 21:23:43 +02:00
|
|
|
MSG msg;
|
|
|
|
while(PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)){
|
|
|
|
TranslateMessage(&msg);
|
|
|
|
DispatchMessageA(&msg);
|
|
|
|
}
|
2010-11-12 22:32:49 +01:00
|
|
|
if(exp_data->missing_events)
|
2010-08-03 21:23:43 +02:00
|
|
|
Sleep(500);
|
|
|
|
}
|
2010-11-12 22:32:49 +01:00
|
|
|
trace("%s: took %d tries\n", exp_data->id, c);
|
2010-08-03 21:23:43 +02:00
|
|
|
}
|
|
|
|
|
2011-09-21 09:54:16 +02:00
|
|
|
static void test_SHChangeNotify(BOOL test_new_delivery)
|
2010-08-03 21:23:43 +02:00
|
|
|
{
|
|
|
|
HWND wnd;
|
2010-11-12 22:32:49 +01:00
|
|
|
ULONG notifyID, i;
|
2010-08-03 21:23:43 +02:00
|
|
|
HRESULT hr;
|
|
|
|
BOOL br, has_unicode;
|
|
|
|
SHChangeNotifyEntry entries[1];
|
|
|
|
const CHAR root_dirA[] = "C:\\shell32_cn_test";
|
|
|
|
const WCHAR root_dirW[] = {'C',':','\\','s','h','e','l','l','3','2','_','c','n','_','t','e','s','t',0};
|
|
|
|
|
2011-09-21 09:54:16 +02:00
|
|
|
trace("SHChangeNotify tests (%x)\n", test_new_delivery);
|
|
|
|
|
2010-08-03 21:23:43 +02:00
|
|
|
CreateDirectoryW(NULL, NULL);
|
|
|
|
has_unicode = !(GetLastError() == ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
|
2011-09-21 09:54:16 +02:00
|
|
|
test_new_delivery_flag = test_new_delivery;
|
|
|
|
if(!test_new_delivery)
|
|
|
|
register_testwindow_class();
|
2010-08-03 21:23:43 +02:00
|
|
|
|
|
|
|
wnd = CreateWindowExA(0, testwindow_class, testwindow_class, 0,
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT, 130, 105,
|
|
|
|
NULL, NULL, GetModuleHandleA(NULL), 0);
|
|
|
|
ok(wnd != NULL, "Failed to make a window\n");
|
|
|
|
|
2010-11-12 22:32:49 +01:00
|
|
|
br = CreateDirectoryA(root_dirA, NULL);
|
|
|
|
ok(br == TRUE, "CreateDirectory failed: %d\n", GetLastError());
|
|
|
|
|
2010-08-03 21:23:43 +02:00
|
|
|
entries[0].pidl = NULL;
|
|
|
|
if(has_unicode)
|
|
|
|
hr = SHILCreateFromPath(root_dirW, (LPITEMIDLIST*)&entries[0].pidl, 0);
|
|
|
|
else
|
|
|
|
hr = SHILCreateFromPath((LPCVOID)root_dirA, (LPITEMIDLIST*)&entries[0].pidl, 0);
|
|
|
|
ok(hr == S_OK, "SHILCreateFromPath failed: 0x%08x\n", hr);
|
|
|
|
entries[0].fRecursive = TRUE;
|
|
|
|
|
2011-09-21 09:54:16 +02:00
|
|
|
notifyID = SHChangeNotifyRegister(wnd, !test_new_delivery ? SHCNRF_ShellLevel : SHCNRF_ShellLevel|SHCNRF_NewDelivery,
|
2010-08-03 21:23:43 +02:00
|
|
|
SHCNE_ALLEVENTS, WM_USER_NOTIFY, 1, entries);
|
|
|
|
ok(notifyID != 0, "Failed to register a window for change notifications\n");
|
|
|
|
|
2010-11-12 22:32:49 +01:00
|
|
|
for(i = 0; i < sizeof(chnotify_tests) / sizeof(*chnotify_tests); ++i){
|
|
|
|
exp_data = chnotify_tests + i;
|
2010-08-03 21:23:43 +02:00
|
|
|
|
2010-11-12 22:32:49 +01:00
|
|
|
exp_data->missing_events = exp_data->notify_count;
|
|
|
|
SHChangeNotify(exp_data->signal, SHCNF_PATHA | SHCNF_FLUSH,
|
|
|
|
strlen(exp_data->path_1) > 0 ? exp_data->path_1 : NULL,
|
|
|
|
strlen(exp_data->path_2) > 0 ? exp_data->path_2 : NULL);
|
2010-08-03 21:23:43 +02:00
|
|
|
do_events();
|
2010-11-12 22:32:49 +01:00
|
|
|
ok(exp_data->missing_events == 0, "%s: Expected wndproc to be called\n", exp_data->id);
|
2010-08-03 21:23:43 +02:00
|
|
|
|
2010-11-12 22:32:49 +01:00
|
|
|
if(has_unicode){
|
|
|
|
WCHAR *path1, *path2;
|
|
|
|
|
|
|
|
path1 = make_wstr(exp_data->path_1);
|
|
|
|
path2 = make_wstr(exp_data->path_2);
|
|
|
|
|
|
|
|
exp_data->missing_events = exp_data->notify_count;
|
|
|
|
SHChangeNotify(exp_data->signal, SHCNF_PATHW | SHCNF_FLUSH, path1, path2);
|
|
|
|
do_events();
|
|
|
|
ok(exp_data->missing_events == 0, "%s: Expected wndproc to be called\n", exp_data->id);
|
2011-01-18 10:45:50 +01:00
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, path1);
|
|
|
|
HeapFree(GetProcessHeap(), 0, path2);
|
2010-11-12 22:32:49 +01:00
|
|
|
}
|
|
|
|
}
|
2010-08-03 21:23:43 +02:00
|
|
|
|
|
|
|
SHChangeNotifyDeregister(notifyID);
|
|
|
|
DestroyWindow(wnd);
|
|
|
|
|
2011-01-22 01:43:59 +01:00
|
|
|
ILFree((LPITEMIDLIST)entries[0].pidl);
|
2010-08-03 21:23:43 +02:00
|
|
|
br = RemoveDirectoryA(root_dirA);
|
|
|
|
ok(br == TRUE, "RemoveDirectory failed: %d\n", GetLastError());
|
|
|
|
}
|
|
|
|
|
2011-08-01 23:47:52 +02:00
|
|
|
static void test_SHCreateDefaultContextMenu(void)
|
|
|
|
{
|
|
|
|
HKEY keys[16];
|
|
|
|
WCHAR path[MAX_PATH];
|
|
|
|
IShellFolder *desktop,*folder;
|
|
|
|
IPersistFolder2 *persist;
|
|
|
|
IContextMenu *cmenu;
|
|
|
|
LONG status;
|
|
|
|
LPITEMIDLIST pidlFolder, pidl_child, pidl;
|
|
|
|
DEFCONTEXTMENU cminfo;
|
|
|
|
HRESULT hr;
|
|
|
|
UINT i;
|
|
|
|
const WCHAR filename[] =
|
|
|
|
{'\\','t','e','s','t','d','i','r','\\','t','e','s','t','1','.','t','x','t',0};
|
|
|
|
if(!pSHCreateDefaultContextMenu)
|
|
|
|
{
|
2011-08-03 23:42:17 +02:00
|
|
|
win_skip("SHCreateDefaultContextMenu missing.\n");
|
2011-08-01 23:47:52 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!pSHBindToParent)
|
|
|
|
{
|
|
|
|
skip("SHBindToParent missing.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
GetCurrentDirectoryW(MAX_PATH, path);
|
|
|
|
if(!lstrlenW(path))
|
|
|
|
{
|
|
|
|
skip("GetCurrentDirectoryW returned an empty string.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
lstrcatW(path, filename);
|
|
|
|
SHGetDesktopFolder(&desktop);
|
|
|
|
|
|
|
|
CreateFilesFolders();
|
|
|
|
|
|
|
|
hr = IShellFolder_ParseDisplayName(desktop, NULL, NULL, path, NULL, &pidl, 0);
|
|
|
|
ok(hr == S_OK || broken(hr == E_FAIL) /* WinME */, "Got 0x%08x\n", hr);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
|
|
|
|
hr = pSHBindToParent(pidl, &IID_IShellFolder, (void**)&folder, (LPCITEMIDLIST*)&pidl_child);
|
|
|
|
ok(hr == S_OK, "Got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
IShellFolder_QueryInterface(folder,&IID_IPersistFolder2,(void**)&persist);
|
|
|
|
IPersistFolder2_GetCurFolder(persist,&pidlFolder);
|
|
|
|
IPersistFolder2_Release(persist);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
|
|
|
|
cminfo.hwnd=NULL;
|
|
|
|
cminfo.pcmcb=NULL;
|
|
|
|
cminfo.psf=folder;
|
|
|
|
cminfo.pidlFolder=NULL;
|
|
|
|
cminfo.apidl=(LPCITEMIDLIST*)&pidl_child;
|
|
|
|
cminfo.cidl=1;
|
|
|
|
cminfo.aKeys=NULL;
|
|
|
|
cminfo.cKeys=0;
|
|
|
|
cminfo.punkAssociationInfo=NULL;
|
|
|
|
hr = pSHCreateDefaultContextMenu(&cminfo,&IID_IContextMenu,(void**)&cmenu);
|
|
|
|
ok(hr==S_OK,"Got 0x%08x\n", hr);
|
|
|
|
IContextMenu_Release(cmenu);
|
|
|
|
cminfo.pidlFolder=pidlFolder;
|
|
|
|
hr = pSHCreateDefaultContextMenu(&cminfo,&IID_IContextMenu,(void**)&cmenu);
|
|
|
|
ok(hr==S_OK,"Got 0x%08x\n", hr);
|
|
|
|
IContextMenu_Release(cmenu);
|
|
|
|
status = RegOpenKeyExA(HKEY_CLASSES_ROOT,"*",0,KEY_READ,keys);
|
|
|
|
if(status==ERROR_SUCCESS){
|
|
|
|
for(i=1;i<16;i++)
|
|
|
|
keys[i]=keys[0];
|
|
|
|
cminfo.aKeys=keys;
|
|
|
|
cminfo.cKeys=16;
|
|
|
|
hr = pSHCreateDefaultContextMenu(&cminfo,&IID_IContextMenu,(void**)&cmenu);
|
|
|
|
RegCloseKey(keys[0]);
|
|
|
|
ok(hr==S_OK,"Got 0x%08x\n", hr);
|
|
|
|
IContextMenu_Release(cmenu);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ILFree(pidlFolder);
|
|
|
|
IShellFolder_Release(folder);
|
|
|
|
}
|
|
|
|
IShellFolder_Release(desktop);
|
|
|
|
ILFree(pidl);
|
|
|
|
Cleanup();
|
|
|
|
}
|
|
|
|
|
2005-06-21 22:04:17 +02:00
|
|
|
START_TEST(shlfolder)
|
|
|
|
{
|
2005-06-22 20:04:04 +02:00
|
|
|
init_function_pointers();
|
2005-06-30 12:23:14 +02:00
|
|
|
/* if OleInitialize doesn't get called, ParseDisplayName returns
|
|
|
|
CO_E_NOTINITIALIZED for malformed directory names on win2k. */
|
|
|
|
OleInitialize(NULL);
|
2005-06-22 20:04:04 +02:00
|
|
|
|
2005-08-02 16:41:51 +02:00
|
|
|
test_ParseDisplayName();
|
2010-03-03 02:56:20 +01:00
|
|
|
test_SHParseDisplayName();
|
2005-06-21 22:04:17 +02:00
|
|
|
test_BindToObject();
|
2005-06-30 12:23:14 +02:00
|
|
|
test_EnumObjects_and_CompareIDs();
|
2005-06-21 22:04:17 +02:00
|
|
|
test_GetDisplayName();
|
|
|
|
test_GetAttributesOf();
|
|
|
|
test_SHGetPathFromIDList();
|
2005-06-24 13:33:35 +02:00
|
|
|
test_CallForAttributes();
|
2005-08-23 11:37:59 +02:00
|
|
|
test_FolderShortcut();
|
2005-12-22 17:16:11 +01:00
|
|
|
test_ITEMIDLIST_format();
|
2010-09-21 13:36:17 +02:00
|
|
|
test_SHGetFolderPathA();
|
2010-03-02 22:00:52 +01:00
|
|
|
test_SHGetFolderPathAndSubDirA();
|
2008-12-02 23:12:08 +01:00
|
|
|
test_LocalizedNames();
|
2010-03-02 22:00:52 +01:00
|
|
|
test_SHCreateShellItem();
|
2010-07-26 11:54:03 +02:00
|
|
|
test_SHCreateShellItemArray();
|
2010-03-21 16:44:44 +01:00
|
|
|
test_desktop_IPersist();
|
2010-07-17 17:08:18 +02:00
|
|
|
test_GetUIObject();
|
2010-07-21 21:04:22 +02:00
|
|
|
test_SHSimpleIDListFromPath();
|
|
|
|
test_ParseDisplayNamePBC();
|
2010-07-22 20:17:02 +02:00
|
|
|
test_SHGetNameFromIDList();
|
2010-07-22 20:17:05 +02:00
|
|
|
test_SHGetItemFromDataObject();
|
2010-07-22 20:17:06 +02:00
|
|
|
test_SHGetIDListFromObject();
|
2010-07-25 19:08:14 +02:00
|
|
|
test_SHGetItemFromObject();
|
2010-07-25 19:08:15 +02:00
|
|
|
test_ShellItemCompare();
|
2011-09-21 09:54:16 +02:00
|
|
|
test_SHChangeNotify(FALSE);
|
|
|
|
test_SHChangeNotify(TRUE);
|
2010-08-16 09:17:30 +02:00
|
|
|
test_ShellItemBindToHandler();
|
2010-12-19 23:15:12 +01:00
|
|
|
test_ShellItemGetAttributes();
|
2011-08-01 23:47:52 +02:00
|
|
|
test_SHCreateDefaultContextMenu();
|
2005-06-30 12:23:14 +02:00
|
|
|
|
|
|
|
OleUninitialize();
|
2005-06-21 22:04:17 +02:00
|
|
|
}
|