ReactOS  0.4.13-dev-249-gcba1a2f
shlfolder.c File Reference
#include <stdarg.h>
#include <stdio.h>
#include "windef.h"
#include "winbase.h"
#include "wtypes.h"
#include "shellapi.h"
#include "shlguid.h"
#include "shlobj.h"
#include "shobjidl.h"
#include "shlwapi.h"
#include "ocidl.h"
#include "oleauto.h"
#include "wine/heap.h"
#include "wine/test.h"
#include <initguid.h>
#include "pshpack1.h"
#include "poppack.h"
Include dependency graph for shlfolder.c:

Go to the source code of this file.

Classes

struct  FileStructA
 
struct  FileStructW
 
struct  IUnknownImpl
 
struct  IUnknownImpl::if_count
 
struct  ChNotifyTest
 

Macros

#define COBJMACROS
 
#define CONST_VTABLE
 
#define MAKEFUNC(f)   (p##f = (void*)GetProcAddress(hmod, #f))
 
#define TESTNAMED(f)
 
#define SFGAO_testfor   SFGAO_FILESYSTEM | SFGAO_FOLDER | SFGAO_FILESYSANCESTOR | SFGAO_CAPABILITYMASK
 
#define SFGAO_VISTA   SFGAO_DROPTARGET | SFGAO_CANLINK | SFGAO_CANCOPY
 
#define verify_pidl(i, p)   r_verify_pidl(__LINE__, i, p)
 
#define WM_USER_NOTIFY   (WM_APP+1)
 

Functions

 DEFINE_GUID (IID_IParentAndItem, 0xB3A4B685, 0xB685, 0x4805, 0x99, 0xD9, 0x5D, 0xEA, 0xD2, 0x87, 0x32, 0x36)
 
 DEFINE_GUID (CLSID_ShellDocObjView, 0xe7e4bc40, 0xe76a, 0x11ce, 0xa9, 0xbb, 0x00, 0xaa, 0x00, 0x4a, 0xe8, 0x37)
 
static HRESULT (WINAPI *pSHCreateItemFromIDList)(PCIDLIST_ABSOLUTE pidl
 
static IBindCtx void **static IBindCtx void **static void **static IShellFolder IShellItem **static IShellFolder LPCITEMIDLIST IShellItemArray **static PCIDLIST_ABSOLUTE IShellItemArray **static void **static void **static PWSTR *static PWSTR *static void **static PIDLIST_ABSOLUTE *static void **static BOOL (WINAPI *pIsWow64Process)(HANDLE
 
static WCHARmake_wstr (const char *str)
 
static int strcmp_wa (LPCWSTR strw, const char *stra)
 
static void init_function_pointers (void)
 
static LPWSTR myPathAddBackslashW (LPWSTR lpszPath)
 
static void test_ParseDisplayName (void)
 
static void CreateTestFile (const CHAR *name)
 
static void CreateFilesFolders (void)
 
static void Cleanup (void)
 
static void test_EnumObjects (IShellFolder *iFolder)
 
static void test_BindToObject (void)
 
static void test_GetDisplayName (void)
 
static void test_CallForAttributes (void)
 
static void test_GetAttributesOf (void)
 
static void test_SHGetPathFromIDList (void)
 
static void test_EnumObjects_and_CompareIDs (void)
 
static HRESULT WINAPI InitPropertyBag_IPropertyBag_QueryInterface (IPropertyBag *iface, REFIID riid, void **ppvObject)
 
static ULONG WINAPI InitPropertyBag_IPropertyBag_AddRef (IPropertyBag *iface)
 
static ULONG WINAPI InitPropertyBag_IPropertyBag_Release (IPropertyBag *iface)
 
static HRESULT WINAPI InitPropertyBag_IPropertyBag_Read (IPropertyBag *iface, LPCOLESTR pszPropName, VARIANT *pVar, IErrorLog *pErrorLog)
 
static HRESULT WINAPI InitPropertyBag_IPropertyBag_Write (IPropertyBag *iface, LPCOLESTR pszPropName, VARIANT *pVar)
 
static void test_FolderShortcut (void)
 
static void test_ITEMIDLIST_format (void)
 
static void test_SHGetFolderPathA (void)
 
static void test_SHGetFolderPathAndSubDirA (void)
 
static void test_LocalizedNames (void)
 
static void test_SHCreateShellItem (void)
 
static void test_SHGetNameFromIDList (void)
 
static void test_SHGetItemFromDataObject (void)
 
static void test_ShellItemCompare (void)
 
static IUnknownImplimpl_from_IUnknown (IUnknown *iface)
 
static HRESULT WINAPI unk_fnQueryInterface (IUnknown *iunk, REFIID riid, void **punk)
 
static ULONG WINAPI unk_fnAddRef (IUnknown *iunk)
 
static ULONG WINAPI unk_fnRelease (IUnknown *iunk)
 
static void test_SHGetIDListFromObject (void)
 
static void test_SHGetItemFromObject (void)
 
static void test_SHCreateShellItemArray (void)
 
static void test_ShellItemArrayEnumItems (void)
 
static void test_ShellItemBindToHandler (void)
 
static void test_ShellItemGetAttributes (void)
 
static void test_ShellItemArrayGetAttributes (void)
 
static WCHARget_empty_cddrive (void)
 
static void test_SHParseDisplayName (void)
 
static void test_desktop_IPersist (void)
 
static void test_contextmenu_qi (IContextMenu *menu, BOOL todo)
 
static void test_contextmenu (IContextMenu *menu, BOOL background)
 
static void test_GetUIObject (void)
 
static void r_verify_pidl (unsigned l, LPCITEMIDLIST pidl, const WCHAR *path)
 
static void test_SHSimpleIDListFromPath (void)
 
static HRESULT WINAPI fsbd_QueryInterface (IFileSystemBindData *fsbd, REFIID riid, void **ppv)
 
static ULONG WINAPI fsbd_AddRef (IFileSystemBindData *fsbd)
 
static ULONG WINAPI fsbd_Release (IFileSystemBindData *fsbd)
 
static HRESULT WINAPI fsbd_SetFindData (IFileSystemBindData *fsbd, const WIN32_FIND_DATAW *pfd)
 
static HRESULT WINAPI fsbd_GetFindData_nul (IFileSystemBindData *fsbd, WIN32_FIND_DATAW *pfd)
 
static HRESULT WINAPI fsbd_GetFindData_junk (IFileSystemBindData *fsbd, WIN32_FIND_DATAW *pfd)
 
static HRESULT WINAPI fsbd_GetFindData_invalid (IFileSystemBindData *fsbd, WIN32_FIND_DATAW *pfd)
 
static HRESULT WINAPI fsbd_GetFindData_valid (IFileSystemBindData *fsbd, WIN32_FIND_DATAW *pfd)
 
static HRESULT WINAPI fsbd_GetFindData_fail (IFileSystemBindData *fsbd, WIN32_FIND_DATAW *pfd)
 
static void test_ParseDisplayNamePBC (void)
 
static LRESULT CALLBACK testwindow_wndproc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
 
static void register_testwindow_class (void)
 
static void do_events (void)
 
static void test_SHChangeNotify (BOOL test_new_delivery)
 
static void test_SHCreateDefaultContextMenu (void)
 
static void test_DataObject (void)
 
static void test_GetDefaultColumn (void)
 
static void test_GetDefaultSearchGUID (void)
 
static void test_SHLimitInputEdit (void)
 
static void test_SHGetSetFolderCustomSettings (void)
 
 START_TEST (shlfolder)
 

Variables

static IMallocppM
 
static REFIID riid
 
static REFIID void ** ppv
 
static IBindCtx REFIID
 
static IBindCtx void **static PCWSTR
 
static IBindCtx void **static IBindCtx void **static DWORD
 
static IBindCtx void **static IBindCtx void **static void **static IShellFolder LPCITEMIDLIST
 
static IBindCtx void **static IBindCtx void **static void **static IShellFolder IShellItem **static IShellFolder UINT
 
static IBindCtx void **static IBindCtx void **static void **static IShellFolder IShellItem **static IShellFolder LPCITEMIDLIST IShellItemArray **static PCIDLIST_ABSOLUTE IShellItemArray **static void **static void **static HANDLE
 
static IBindCtx void **static IBindCtx void **static void **static IShellFolder IShellItem **static IShellFolder LPCITEMIDLIST IShellItemArray **static PCIDLIST_ABSOLUTE IShellItemArray **static void **static void **static PWSTR *static SIGDN
 
static IBindCtx void **static IBindCtx void **static void **static IShellFolder IShellItem **static IShellFolder LPCITEMIDLIST IShellItemArray **static PCIDLIST_ABSOLUTE IShellItemArray **static void **static void **static PWSTR *static PWSTR *static DATAOBJ_GET_ITEM_FLAGS
 
static IBindCtx void **static IBindCtx void **static void **static IShellFolder IShellItem **static IShellFolder LPCITEMIDLIST IShellItemArray **static PCIDLIST_ABSOLUTE IShellItemArray **static void **static void **static PWSTR *static PWSTR *static void **static PIDLIST_ABSOLUTE *static void **static PBOOL
 
static void **static WCHAR GPFIDL_FLAGS
 
struct {
   WCHAR   path [MAX_PATH]
 
   HRESULT   hr
 
   int   todo
 
parse_tests []
 
static const IPropertyBagVtbl InitPropertyBag_IPropertyBagVtbl
 
static struct IPropertyBag InitPropertyBag
 
static const IUnknownVtbl vt_IUnknown
 
static IFileSystemBindDataVtbl fsbdVtbl
 
static IFileSystemBindData fsbd = { &fsbdVtbl }
 
static const CHAR testwindow_class [] = "testwindow"
 
struct ChNotifyTest chnotify_tests []
 
struct ChNotifyTestexp_data
 
BOOL test_new_delivery_flag
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 24 of file shlfolder.c.

◆ CONST_VTABLE

#define CONST_VTABLE

Definition at line 25 of file shlfolder.c.

◆ MAKEFUNC

#define MAKEFUNC (   f)    (p##f = (void*)GetProcAddress(hmod, #f))

◆ SFGAO_testfor

#define SFGAO_testfor   SFGAO_FILESYSTEM | SFGAO_FOLDER | SFGAO_FILESYSANCESTOR | SFGAO_CAPABILITYMASK

◆ SFGAO_VISTA

#define SFGAO_VISTA   SFGAO_DROPTARGET | SFGAO_CANLINK | SFGAO_CANCOPY

◆ TESTNAMED

#define TESTNAMED (   f)
Value:
ptr = (void*)GetProcAddress(hmod, #f); \
ok(ptr != 0, "expected named export for " #f "\n");
static PVOID ptr
Definition: dispmode.c:27
GLfloat f
Definition: glext.h:7540
static PEXPLICIT_ACCESSW *static HMODULE hmod
Definition: security.c:141
#define GetProcAddress(x, y)
Definition: compat.h:410

◆ verify_pidl

#define verify_pidl (   i,
  p 
)    r_verify_pidl(__LINE__, i, p)

Definition at line 4524 of file shlfolder.c.

◆ WM_USER_NOTIFY

#define WM_USER_NOTIFY   (WM_APP+1)

Definition at line 4851 of file shlfolder.c.

Function Documentation

◆ BOOL()

static IBindCtx void** static IBindCtx void** static void** static IShellFolder IShellItem** static IShellFolder LPCITEMIDLIST IShellItemArray** static PCIDLIST_ABSOLUTE IShellItemArray** static void** static void** static PWSTR* static PWSTR* static void** static PIDLIST_ABSOLUTE* static void** static BOOL ( WINAPI pIsWow64Process)
static

◆ Cleanup()

static void Cleanup ( void  )
static

Definition at line 308 of file shlfolder.c.

309 {
310  DeleteFileA(".\\testdir\\test1.txt");
311  DeleteFileA(".\\testdir\\test2.txt");
312  DeleteFileA(".\\testdir\\test3.txt");
313  RemoveDirectoryA(".\\testdir\\test.txt");
314  RemoveDirectoryA(".\\testdir\\testdir2\\subdir");
315  RemoveDirectoryA(".\\testdir\\testdir2");
316  RemoveDirectoryA(".\\testdir");
317 }
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
BOOL WINAPI RemoveDirectoryA(IN LPCSTR lpPathName)
Definition: dir.c:714

Referenced by test_EnumObjects_and_CompareIDs(), test_GetAttributesOf(), test_GetUIObject(), test_SHCreateDefaultContextMenu(), test_SHCreateShellItemArray(), test_ShellItemArrayGetAttributes(), and test_ShellItemGetAttributes().

◆ CreateFilesFolders()

static void CreateFilesFolders ( void  )
static

Definition at line 296 of file shlfolder.c.

297 {
298  CreateDirectoryA(".\\testdir", NULL);
299  CreateDirectoryA(".\\testdir\\test.txt", NULL);
300  CreateTestFile (".\\testdir\\test1.txt ");
301  CreateTestFile (".\\testdir\\test2.txt ");
302  CreateTestFile (".\\testdir\\test3.txt ");
303  CreateDirectoryA(".\\testdir\\testdir2 ", NULL);
304  CreateDirectoryA(".\\testdir\\testdir2\\subdir", NULL);
305 }
BOOL WINAPI CreateDirectoryA(IN LPCSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:37
smooth NULL
Definition: ftsmooth.c:416
static void CreateTestFile(const CHAR *name)
Definition: shlfolder.c:280

Referenced by test_EnumObjects_and_CompareIDs(), test_GetAttributesOf(), test_GetUIObject(), test_SHCreateDefaultContextMenu(), test_SHCreateShellItemArray(), test_ShellItemArrayEnumItems(), test_ShellItemArrayGetAttributes(), and test_ShellItemGetAttributes().

◆ CreateTestFile()

static void CreateTestFile ( const CHAR name)
static

Definition at line 280 of file shlfolder.c.

281 {
282  HANDLE file;
283  DWORD written;
284 
286  if (file != INVALID_HANDLE_VALUE)
287  {
288  WriteFile(file, name, strlen(name), &written, NULL);
289  WriteFile(file, "\n", strlen("\n"), &written, NULL);
290  CloseHandle(file);
291  }
292 }
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define CloseHandle
Definition: compat.h:398
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
const char file[]
Definition: icontest.c:11
unsigned long DWORD
Definition: ntddk_ex.h:95
#define CREATE_ALWAYS
Definition: disk.h:72
Definition: name.c:36
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:399
Definition: fci.c:126

Referenced by CreateFilesFolders(), test_SHCreateShellItem(), and test_ShellItemCompare().

◆ DEFINE_GUID() [1/2]

DEFINE_GUID ( IID_IParentAndItem  ,
0xB3A4B685  ,
0xB685  ,
0x4805  ,
0x99  ,
0xD9  ,
0x5D  ,
0xEA  ,
0xD2  ,
0x87  ,
0x32  ,
0x36   
)

◆ DEFINE_GUID() [2/2]

DEFINE_GUID ( CLSID_ShellDocObjView  ,
0xe7e4bc40  ,
0xe76a  ,
0x11ce  ,
0xa9  ,
0xbb  ,
0x00  ,
0xaa  ,
0x00  ,
0x4a  ,
0xe8  ,
0x37   
)

◆ do_events()

static void do_events ( void  )
static

Definition at line 4927 of file shlfolder.c.

4928 {
4929  int c = 0;
4930  while (exp_data->missing_events && (c++ < 10)){
4931  MSG msg;
4932  while(PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)){
4935  }
4936  if(exp_data->missing_events)
4937  Sleep(500);
4938  }
4939  trace("%s: took %d tries\n", exp_data->id, c);
4940 }
#define trace(...)
Definition: kmt_test.h:217
BOOL WINAPI TranslateMessage(_In_ const MSG *)
LRESULT WINAPI DispatchMessageA(_In_ const MSG *)
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:736
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
BOOL WINAPI PeekMessageA(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
struct ChNotifyTest * exp_data
Definition: shlfolder.c:4866
smooth NULL
Definition: ftsmooth.c:416
const GLubyte * c
Definition: glext.h:8905
#define msg(x)
Definition: auth_time.c:54
#define PM_REMOVE
Definition: winuser.h:1182

Referenced by test_SHChangeNotify().

◆ fsbd_AddRef()

static ULONG WINAPI fsbd_AddRef ( IFileSystemBindData fsbd)
static

Definition at line 4609 of file shlfolder.c.

4610 {
4611  return 2;
4612 }

◆ fsbd_GetFindData_fail()

static HRESULT WINAPI fsbd_GetFindData_fail ( IFileSystemBindData fsbd,
WIN32_FIND_DATAW pfd 
)
static

Definition at line 4658 of file shlfolder.c.

4660 {
4661  return E_FAIL;
4662 }
#define E_FAIL
Definition: ddrawi.h:102

Referenced by test_ParseDisplayNamePBC().

◆ fsbd_GetFindData_invalid()

static HRESULT WINAPI fsbd_GetFindData_invalid ( IFileSystemBindData fsbd,
WIN32_FIND_DATAW pfd 
)
static

Definition at line 4640 of file shlfolder.c.

4642 {
4643  memset(pfd, 0, sizeof(WIN32_FIND_DATAW));
4644  *pfd->cFileName = 'a';
4645  *pfd->cAlternateFileName = 'a';
4646  return S_OK;
4647 }
static PIXELFORMATDESCRIPTOR pfd
Definition: ssstars.c:67
#define S_OK
Definition: intsafe.h:59
#define memset(x, y, z)
Definition: compat.h:39

Referenced by test_ParseDisplayNamePBC().

◆ fsbd_GetFindData_junk()

static HRESULT WINAPI fsbd_GetFindData_junk ( IFileSystemBindData fsbd,
WIN32_FIND_DATAW pfd 
)
static

Definition at line 4633 of file shlfolder.c.

4635 {
4636  memset(pfd, 0xef, sizeof(WIN32_FIND_DATAW));
4637  return S_OK;
4638 }
static PIXELFORMATDESCRIPTOR pfd
Definition: ssstars.c:67
#define S_OK
Definition: intsafe.h:59
#define memset(x, y, z)
Definition: compat.h:39

Referenced by test_ParseDisplayNamePBC().

◆ fsbd_GetFindData_nul()

static HRESULT WINAPI fsbd_GetFindData_nul ( IFileSystemBindData fsbd,
WIN32_FIND_DATAW pfd 
)
static

Definition at line 4626 of file shlfolder.c.

4628 {
4629  memset(pfd, 0, sizeof(WIN32_FIND_DATAW));
4630  return S_OK;
4631 }
static PIXELFORMATDESCRIPTOR pfd
Definition: ssstars.c:67
#define S_OK
Definition: intsafe.h:59
#define memset(x, y, z)
Definition: compat.h:39

Referenced by test_ParseDisplayNamePBC().

◆ fsbd_GetFindData_valid()

static HRESULT WINAPI fsbd_GetFindData_valid ( IFileSystemBindData fsbd,
WIN32_FIND_DATAW pfd 
)
static

Definition at line 4649 of file shlfolder.c.

4651 {
4652  static const WCHAR adirW[] = {'C',':','\\','f','s','b','d','d','i','r',0};
4653  HANDLE handle = FindFirstFileW(adirW, pfd);
4654  FindClose(handle);
4655  return S_OK;
4656 }
__wchar_t WCHAR
Definition: xmlstorage.h:180
static PIXELFORMATDESCRIPTOR pfd
Definition: ssstars.c:67
#define S_OK
Definition: intsafe.h:59
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502

Referenced by test_ParseDisplayNamePBC().

◆ fsbd_QueryInterface()

static HRESULT WINAPI fsbd_QueryInterface ( IFileSystemBindData fsbd,
REFIID  riid,
void **  ppv 
)
static

Definition at line 4598 of file shlfolder.c.

4600 {
4601  if(IsEqualIID(riid, &IID_IFileSystemBindData) ||
4603  *ppv = fsbd;
4604  return S_OK;
4605  }
4606  return E_NOINTERFACE;
4607 }
#define E_NOINTERFACE
Definition: winerror.h:2364
REFIID riid
Definition: precomp.h:44
REFIID LPVOID * ppv
Definition: atlbase.h:39
static IFileSystemBindData fsbd
Definition: shlfolder.c:4672
const GUID IID_IUnknown
#define S_OK
Definition: intsafe.h:59
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:90

◆ fsbd_Release()

static ULONG WINAPI fsbd_Release ( IFileSystemBindData fsbd)
static

Definition at line 4614 of file shlfolder.c.

4615 {
4616  return 1;
4617 }

◆ fsbd_SetFindData()

static HRESULT WINAPI fsbd_SetFindData ( IFileSystemBindData fsbd,
const WIN32_FIND_DATAW pfd 
)
static

Definition at line 4619 of file shlfolder.c.

4621 {
4622  ok(0, "SetFindData called\n");
4623  return E_NOTIMPL;
4624 }
#define ok(value,...)
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ get_empty_cddrive()

static WCHAR* get_empty_cddrive ( void  )
static

Definition at line 4218 of file shlfolder.c.

4219 {
4220  static WCHAR cdrom_drive[] = {'A',':','\\',0};
4221  DWORD drives = GetLogicalDrives();
4222 
4223  cdrom_drive[0] = 'A';
4224  while (drives)
4225  {
4226  if ((drives & 1) &&
4227  GetDriveTypeW(cdrom_drive) == DRIVE_CDROM &&
4229  {
4230  return cdrom_drive;
4231  }
4232 
4233  drives = drives >> 1;
4234  cdrom_drive[0]++;
4235  }
4236  return NULL;
4237 }
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:802
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
UINT WINAPI GetDriveTypeW(IN LPCWSTR lpRootPathName)
Definition: disk.c:497
DWORD WINAPI GetLogicalDrives(VOID)
Definition: disk.c:110
#define DRIVE_CDROM
Definition: winbase.h:251

Referenced by test_SHParseDisplayName().

◆ HRESULT()

static HRESULT ( WINAPI pSHCreateItemFromIDList)
static

◆ impl_from_IUnknown()

static IUnknownImpl* impl_from_IUnknown ( IUnknown iface)
inlinestatic

Definition at line 2981 of file shlfolder.c.

2982 {
2983  return CONTAINING_RECORD(iface, IUnknownImpl, IUnknown_iface);
2984 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

Referenced by unk_fnQueryInterface().

◆ init_function_pointers()

static void init_function_pointers ( void  )
static

Definition at line 98 of file shlfolder.c.

99 {
100  HMODULE hmod;
101  HRESULT hr;
102  void *ptr;
103 
104  hmod = GetModuleHandleA("shell32.dll");
105 
106 #define MAKEFUNC(f) (p##f = (void*)GetProcAddress(hmod, #f))
109  MAKEFUNC(SHCreateItemFromRelativeName);
110  MAKEFUNC(SHCreateItemInKnownFolder);
116  MAKEFUNC(SHGetKnownFolderPath);
122  MAKEFUNC(SHGetPathFromIDListEx);
123  MAKEFUNC(SHGetSetFolderCustomSettings);
124 #undef MAKEFUNC
125 
126  /* test named exports */
127  ptr = GetProcAddress(hmod, "ILFree");
128  ok(broken(ptr == 0) || ptr != 0, "expected named export for ILFree\n");
129  if (ptr)
130  {
131 #define TESTNAMED(f) \
132  ptr = (void*)GetProcAddress(hmod, #f); \
133  ok(ptr != 0, "expected named export for " #f "\n");
134 
150 #undef TESTNAMED
151  }
152 
153  hmod = GetModuleHandleA("kernel32.dll");
154  pIsWow64Process = (void*)GetProcAddress(hmod, "IsWow64Process");
155 
156  hr = SHGetMalloc(&ppM);
157  ok(hr == S_OK, "SHGetMalloc failed %08x\n", hr);
158 }
HRESULT WINAPI SHCreateShellItemArrayFromIDLists(UINT cidl, PCIDLIST_ABSOLUTE_ARRAY pidl_array, IShellItemArray **psia)
HRESULT hr
Definition: shlfolder.c:183
HRESULT WINAPI SHGetItemFromDataObject(IDataObject *pdtobj, DATAOBJ_GET_ITEM_FLAGS dwFlags, REFIID riid, void **ppv)
HRESULT WINAPI SHCreateItemFromParsingName(PCWSTR pszPath, IBindCtx *pbc, REFIID riid, void **ppv)
HRESULT WINAPI SHCreateDefaultContextMenu(const DEFCONTEXTMENU *pdcm, REFIID riid, void **ppv)
LPITEMIDLIST WINAPI ILCombine(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:699
LPITEMIDLIST WINAPI ILGetNext(LPCITEMIDLIST pidl)
Definition: pidl.c:851
HRESULT WINAPI SHGetMalloc(LPMALLOC *lpmal)
Definition: shellole.c:290
BOOL WINAPI ILIsEqual(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:535
BOOL WINAPI ILRemoveLastID(LPITEMIDLIST pidl)
Definition: pidl.c:212
#define ILCreateFromPath
Definition: shlobj.h:2297
HRESULT WINAPI SHGetItemFromObject(IUnknown *punk, REFIID riid, void **ppv)
HRESULT WINAPI ILSaveToStream(IStream *pStream, LPCITEMIDLIST pPidl)
Definition: pidl.c:342
LPITEMIDLIST WINAPI ILCreateFromPathA(LPCSTR path)
Definition: pidl.c:966
HRESULT WINAPI SHGetNameFromIDList(PCIDLIST_ABSOLUTE pidl, SIGDN sigdnName, PWSTR *ppszName)
Definition: pidl.c:1409
static PVOID ptr
Definition: dispmode.c:27
#define ok(value,...)
LPITEMIDLIST WINAPI ILFindLastID(LPCITEMIDLIST pidl)
Definition: pidl.c:189
#define TESTNAMED(f)
LPITEMIDLIST WINAPI ILAppendID(LPITEMIDLIST pidl, LPCSHITEMID item, BOOL bEnd)
Definition: pidl.c:885
LPITEMIDLIST WINAPI ILFindChild(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:641
LONG HRESULT
Definition: typedefs.h:77
HRESULT WINAPI SHGetIDListFromObject(IUnknown *punk, PIDLIST_ABSOLUTE *ppidl)
Definition: pidl.c:1472
EXTERN_C HRESULT WINAPI SHCreateShellItem(LPCITEMIDLIST pidlParent, IShellFolder *psfParent, LPCITEMIDLIST pidl, IShellItem **ppsi)
Definition: CShellItem.cpp:264
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:819
HRESULT WINAPI SHCreateShellItemArrayFromShellItem(IShellItem *psi, REFIID riid, void **ppv)
LPITEMIDLIST WINAPI ILCloneFirst(LPCITEMIDLIST pidl)
Definition: pidl.c:253
#define broken(x)
Definition: _sntprintf.h:21
static PEXPLICIT_ACCESSW *static HMODULE hmod
Definition: security.c:141
BOOL WINAPI ILIsParent(LPCITEMIDLIST pidlParent, LPCITEMIDLIST pidlChild, BOOL bImmediate)
Definition: pidl.c:592
#define S_OK
Definition: intsafe.h:59
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition: pidl.c:228
static IMalloc * ppM
Definition: shlfolder.c:47
#define ILGetSize
Definition: shellclasses.h:638
#define GetProcAddress(x, y)
Definition: compat.h:410
HRESULT WINAPI SHCreateItemFromIDList(PCIDLIST_ABSOLUTE pidl, REFIID riid, void **ppv)
LPITEMIDLIST WINAPI ILCreateFromPathW(LPCWSTR path)
Definition: pidl.c:982
HRESULT WINAPI SHCreateShellItemArrayFromDataObject(IDataObject *pdo, REFIID riid, void **ppv)
#define MAKEFUNC(f)
HRESULT WINAPI SHCreateShellItemArray(PCIDLIST_ABSOLUTE pidlParent, IShellFolder *psf, UINT cidl, PCUITEMID_CHILD_ARRAY ppidl, IShellItemArray **ppsiItemArray)

Referenced by START_TEST().

◆ InitPropertyBag_IPropertyBag_AddRef()

static ULONG WINAPI InitPropertyBag_IPropertyBag_AddRef ( IPropertyBag iface)
static

Definition at line 1276 of file shlfolder.c.

1276  {
1277  return 2;
1278 }

◆ InitPropertyBag_IPropertyBag_QueryInterface()

static HRESULT WINAPI InitPropertyBag_IPropertyBag_QueryInterface ( IPropertyBag iface,
REFIID  riid,
void **  ppvObject 
)
static

Definition at line 1259 of file shlfolder.c.

1261 {
1262  if (!ppvObject)
1263  return E_INVALIDARG;
1264 
1266  *ppvObject = iface;
1267  } else {
1268  ok (FALSE, "InitPropertyBag asked for unknown interface!\n");
1269  return E_NOINTERFACE;
1270  }
1271 
1272  IPropertyBag_AddRef(iface);
1273  return S_OK;
1274 }
#define E_NOINTERFACE
Definition: winerror.h:2364
REFIID riid
Definition: precomp.h:44
#define ok(value,...)
#define E_INVALIDARG
Definition: ddrawi.h:101
const GUID IID_IPropertyBag
const GUID IID_IUnknown
REFIID LPVOID * ppvObject
Definition: precomp.h:44
#define S_OK
Definition: intsafe.h:59
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:90

◆ InitPropertyBag_IPropertyBag_Read()

static HRESULT WINAPI InitPropertyBag_IPropertyBag_Read ( IPropertyBag iface,
LPCOLESTR  pszPropName,
VARIANT pVar,
IErrorLog pErrorLog 
)
static

Definition at line 1284 of file shlfolder.c.

1286 {
1287  static const WCHAR wszTargetSpecialFolder[] = {
1288  'T','a','r','g','e','t','S','p','e','c','i','a','l','F','o','l','d','e','r',0 };
1289  static const WCHAR wszTarget[] = {
1290  'T','a','r','g','e','t',0 };
1291  static const WCHAR wszAttributes[] = {
1292  'A','t','t','r','i','b','u','t','e','s',0 };
1293  static const WCHAR wszResolveLinkFlags[] = {
1294  'R','e','s','o','l','v','e','L','i','n','k','F','l','a','g','s',0 };
1295  static const WCHAR wszTargetKnownFolder[] = {
1296  'T','a','r','g','e','t','K','n','o','w','n','F','o','l','d','e','r',0 };
1297  static const WCHAR wszCLSID[] = {
1298  'C','L','S','I','D',0 };
1299 
1300  if (!lstrcmpW(pszPropName, wszTargetSpecialFolder)) {
1301  ok(V_VT(pVar) == VT_I4, "Wrong variant type for 'TargetSpecialFolder' property!\n");
1302  return E_INVALIDARG;
1303  }
1304 
1305  if (!lstrcmpW(pszPropName, wszResolveLinkFlags))
1306  {
1307  ok(V_VT(pVar) == VT_UI4, "Wrong variant type for 'ResolveLinkFlags' property!\n");
1308  return E_INVALIDARG;
1309  }
1310 
1311  if (!lstrcmpW(pszPropName, wszTarget)) {
1312  WCHAR wszPath[MAX_PATH];
1313  BOOL result;
1314 
1315  ok(V_VT(pVar) == VT_BSTR, "Wrong variant type for 'Target' property!\n");
1316  if (V_VT(pVar) != VT_BSTR) return E_INVALIDARG;
1317 
1319  ok(result, "SHGetSpecialFolderPathW(DESKTOPDIRECTORY) failed! %u\n", GetLastError());
1320  if (!result) return E_INVALIDARG;
1321 
1322  V_BSTR(pVar) = SysAllocString(wszPath);
1323  return S_OK;
1324  }
1325 
1326  if (!lstrcmpW(pszPropName, wszAttributes)) {
1327  ok(V_VT(pVar) == VT_UI4, "Wrong variant type for 'Attributes' property!\n");
1328  if (V_VT(pVar) != VT_UI4) return E_INVALIDARG;
1329  V_UI4(pVar) = SFGAO_FOLDER|SFGAO_HASSUBFOLDER|SFGAO_FILESYSANCESTOR|
1330  SFGAO_CANRENAME|SFGAO_FILESYSTEM;
1331  return S_OK;
1332  }
1333 
1334  if (!lstrcmpW(pszPropName, wszTargetKnownFolder)) {
1335  ok(V_VT(pVar) == VT_BSTR, "Wrong variant type for 'TargetKnownFolder' property!\n");
1336  /* TODO */
1337  return E_INVALIDARG;
1338  }
1339 
1340  if (!lstrcmpW(pszPropName, wszCLSID)) {
1341  ok(V_VT(pVar) == VT_EMPTY, "Wrong variant type for 'CLSID' property!\n");
1342  /* TODO */
1343  return E_INVALIDARG;
1344  }
1345 
1346  ok(FALSE, "PropertyBag was asked for unknown property %s (vt=%d)!\n", wine_dbgstr_w(pszPropName), V_VT(pVar));
1347  return E_INVALIDARG;
1348 }
Definition: compat.h:1939
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
#define wine_dbgstr_w
Definition: kernel32.h:34
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ok(value,...)
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:241
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
#define V_UI4(A)
Definition: oleauto.h:270
#define V_VT(A)
Definition: oleauto.h:211
#define V_BSTR(A)
Definition: oleauto.h:226
#define S_OK
Definition: intsafe.h:59
BOOL WINAPI SHGetSpecialFolderPathW(HWND hwndOwner, LPWSTR szPath, int nFolder, BOOL bCreate)
Definition: shellpath.c:2566
#define CSIDL_DESKTOPDIRECTORY
Definition: shlobj.h:2018
GLuint64EXT * result
Definition: glext.h:11304

◆ InitPropertyBag_IPropertyBag_Release()

static ULONG WINAPI InitPropertyBag_IPropertyBag_Release ( IPropertyBag iface)
static

Definition at line 1280 of file shlfolder.c.

1280  {
1281  return 1;
1282 }

◆ InitPropertyBag_IPropertyBag_Write()

static HRESULT WINAPI InitPropertyBag_IPropertyBag_Write ( IPropertyBag iface,
LPCOLESTR  pszPropName,
VARIANT pVar 
)
static

Definition at line 1350 of file shlfolder.c.

1352 {
1353  ok(FALSE, "Unexpected call to IPropertyBag_Write\n");
1354  return E_NOTIMPL;
1355 }
#define ok(value,...)
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ make_wstr()

static WCHAR* make_wstr ( const char str)
static

Definition at line 71 of file shlfolder.c.

72 {
73  WCHAR *ret;
74  int len;
75 
76  if (!str || !str[0])
77  return NULL;
78 
79  len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
80  if(!len || len < 0)
81  return NULL;
82 
83  ret = heap_alloc(len * sizeof(WCHAR));
84  if(!ret)
85  return NULL;
86 
88  return ret;
89 }
#define CP_ACP
Definition: compat.h:99
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
int ret
GLenum GLsizei len
Definition: glext.h:6722
#define MultiByteToWideChar
Definition: compat.h:100

Referenced by test_SHChangeNotify(), and testwindow_wndproc().

◆ myPathAddBackslashW()

static LPWSTR myPathAddBackslashW ( LPWSTR  lpszPath)
static

Definition at line 161 of file shlfolder.c.

162 {
163  size_t iLen;
164 
165  if (!lpszPath || (iLen = lstrlenW(lpszPath)) >= MAX_PATH)
166  return NULL;
167 
168  if (iLen)
169  {
170  lpszPath += iLen;
171  if (lpszPath[-1] != '\\')
172  {
173  *lpszPath++ = '\\';
174  *lpszPath = '\0';
175  }
176  }
177  return lpszPath;
178 }
#define lstrlenW
Definition: compat.h:407
smooth NULL
Definition: ftsmooth.c:416
#define MAX_PATH
Definition: compat.h:26

Referenced by test_FolderShortcut(), test_SHCreateShellItem(), test_SHCreateShellItemArray(), test_ShellItemArrayEnumItems(), test_ShellItemArrayGetAttributes(), test_ShellItemGetAttributes(), and test_SHGetPathFromIDList().

◆ r_verify_pidl()

static void r_verify_pidl ( unsigned  l,
LPCITEMIDLIST  pidl,
const WCHAR path 
)
static

Definition at line 4525 of file shlfolder.c.

4526 {
4529  STRRET filename;
4530  HRESULT hr;
4531 
4532  if(path){
4533  if(!pidl){
4534  ok_(__FILE__,l)(0, "didn't get expected path (%s), instead: NULL\n", wine_dbgstr_w(path));
4535  return;
4536  }
4537 
4538  hr = SHBindToParent(pidl, &IID_IShellFolder, (void **)&parent, &child);
4539  ok_(__FILE__,l)(hr == S_OK, "SHBindToParent failed: 0x%08x\n", hr);
4540  if(FAILED(hr))
4541  return;
4542 
4543  hr = IShellFolder_GetDisplayNameOf(parent, child, SHGDN_FORPARSING, &filename);
4544  ok_(__FILE__,l)(hr == S_OK, "GetDisplayNameOf failed: 0x%08x\n", hr);
4545  if(FAILED(hr)){
4546  IShellFolder_Release(parent);
4547  return;
4548  }
4549 
4550  ok_(__FILE__,l)(filename.uType == STRRET_WSTR || filename.uType == STRRET_CSTR,
4551  "Got unexpected string type: %d\n", filename.uType);
4552  if(filename.uType == STRRET_WSTR){
4553  ok_(__FILE__,l)(lstrcmpW(path, U(filename).pOleStr) == 0,
4554  "didn't get expected path (%s), instead: %s\n",
4555  wine_dbgstr_w(path), wine_dbgstr_w(U(filename).pOleStr));
4556  SHFree(U(filename).pOleStr);
4557  }else if(filename.uType == STRRET_CSTR){
4558  ok_(__FILE__,l)(strcmp_wa(path, U(filename).cStr) == 0,
4559  "didn't get expected path (%s), instead: %s\n",
4560  wine_dbgstr_w(path), U(filename).cStr);
4561  }
4562 
4563  IShellFolder_Release(parent);
4564  }else
4565  ok_(__FILE__,l)(pidl == NULL, "Expected PIDL to be NULL\n");
4566 }
HRESULT hr
Definition: shlfolder.c:183
#define ok_(x1, x2)
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
#define U(x)
Definition: wordpad.c:44
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
#define wine_dbgstr_w
Definition: kernel32.h:34
const char * filename
Definition: ioapi.h:135
static HWND child
Definition: cursoricon.c:298
smooth NULL
Definition: ftsmooth.c:416
r l[0]
Definition: byte_order.h:167
r parent
Definition: btrfs.c:2677
LONG HRESULT
Definition: typedefs.h:77
static int strcmp_wa(LPCWSTR strw, const char *stra)
Definition: shlfolder.c:91
#define S_OK
Definition: intsafe.h:59
HRESULT WINAPI SHBindToParent(LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppv, LPCITEMIDLIST *ppidlLast)
Definition: pidl.c:1323
Definition: services.c:325
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:331

◆ register_testwindow_class()

static void register_testwindow_class ( void  )
static

Definition at line 4908 of file shlfolder.c.

4909 {
4910  WNDCLASSEXA cls;
4911  ATOM ret;
4912 
4913  ZeroMemory(&cls, sizeof(cls));
4914  cls.cbSize = sizeof(cls);
4915  cls.style = 0;
4919 
4920  SetLastError(0);
4921  ret = RegisterClassExA(&cls);
4922  ok(ret != 0, "RegisterClassExA failed: %d\n", GetLastError());
4923 }
UINT style
Definition: winuser.h:3155
WNDPROC lpfnWndProc
Definition: winuser.h:3156
LPCSTR lpszClassName
Definition: winuser.h:3164
WORD ATOM
Definition: dimm.idl:113
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define ZeroMemory
Definition: winbase.h:1635
HINSTANCE hInstance
Definition: winuser.h:3159
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
static LRESULT CALLBACK testwindow_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: shlfolder.c:4869
UINT cbSize
Definition: winuser.h:3154
#define SetLastError(x)
Definition: compat.h:409
int ret
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:819
ATOM WINAPI RegisterClassExA(_In_ CONST WNDCLASSEXA *)
static const CHAR testwindow_class[]
Definition: shlfolder.c:4850

Referenced by test_SHChangeNotify().

◆ START_TEST()

START_TEST ( shlfolder  )

Definition at line 5338 of file shlfolder.c.

5339 {
5341  /* if OleInitialize doesn't get called, ParseDisplayName returns
5342  CO_E_NOTINITIALIZED for malformed directory names */
5344 
5362  test_GetUIObject();
5376  test_DataObject();
5381 
5382  OleUninitialize();
5383 }
static void test_desktop_IPersist(void)
Definition: shlfolder.c:4323
static void test_EnumObjects_and_CompareIDs(void)
Definition: shlfolder.c:1211
static void test_ParseDisplayName(void)
Definition: shlfolder.c:207
static void test_CallForAttributes(void)
Definition: shlfolder.c:806
static void init_function_pointers(void)
Definition: shlfolder.c:98
#define TRUE
Definition: types.h:120
static void test_SHGetNameFromIDList(void)
Definition: shlfolder.c:2486
static void test_SHGetIDListFromObject(void)
Definition: shlfolder.c:3021
static void test_SHGetPathFromIDList(void)
Definition: shlfolder.c:1065
static void test_ShellItemGetAttributes(void)
Definition: shlfolder.c:4029
static void test_ParseDisplayNamePBC(void)
Definition: shlfolder.c:4674
static void test_FolderShortcut(void)
Definition: shlfolder.c:1369
static void test_GetDefaultColumn(void)
Definition: shlfolder.c:5157
static void test_ShellItemBindToHandler(void)
Definition: shlfolder.c:3865
static void test_ShellItemArrayEnumItems(void)
Definition: shlfolder.c:3711
static void test_SHCreateShellItemArray(void)
Definition: shlfolder.c:3264
static void test_LocalizedNames(void)
Definition: shlfolder.c:1896
static void test_BindToObject(void)
Definition: shlfolder.c:416
static void test_ShellItemCompare(void)
Definition: shlfolder.c:2744
static void test_SHGetSetFolderCustomSettings(void)
Definition: shlfolder.c:5286
static void test_SHGetFolderPathA(void)
Definition: shlfolder.c:1712
smooth NULL
Definition: ftsmooth.c:416
static void test_DataObject(void)
Definition: shlfolder.c:5100
static void test_SHCreateShellItem(void)
Definition: shlfolder.c:1998
static void test_GetDisplayName(void)
Definition: shlfolder.c:639
static void test_SHSimpleIDListFromPath(void)
Definition: shlfolder.c:4568
static void test_ITEMIDLIST_format(void)
Definition: shlfolder.c:1562
static void test_SHParseDisplayName(void)
Definition: shlfolder.c:4239
static void test_SHCreateDefaultContextMenu(void)
Definition: shlfolder.c:5016
static void test_GetDefaultSearchGUID(void)
Definition: shlfolder.c:5210
static void test_SHGetItemFromDataObject(void)
Definition: shlfolder.c:2631
static void test_SHGetFolderPathAndSubDirA(void)
Definition: shlfolder.c:1794
HRESULT WINAPI DECLSPEC_HOTPATCH OleInitialize(LPVOID reserved)
Definition: ole2.c:172
static void test_SHChangeNotify(BOOL test_new_delivery)
Definition: shlfolder.c:4942
static void test_SHGetItemFromObject(void)
Definition: shlfolder.c:3189
static void test_SHLimitInputEdit(void)
Definition: shlfolder.c:5258
void WINAPI DECLSPEC_HOTPATCH OleUninitialize(void)
Definition: ole2.c:233
static void test_GetUIObject(void)
Definition: shlfolder.c:4476
static void test_ShellItemArrayGetAttributes(void)
Definition: shlfolder.c:4121
static void test_GetAttributesOf(void)
Definition: shlfolder.c:928

◆ strcmp_wa()

static int strcmp_wa ( LPCWSTR  strw,
const char stra 
)
static

Definition at line 91 of file shlfolder.c.

92 {
93  CHAR buf[512];
94  WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), NULL, NULL);
95  return lstrcmpA(stra, buf);
96 }
#define WideCharToMultiByte
Definition: compat.h:101
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define CP_ACP
Definition: compat.h:99
char CHAR
Definition: xmlstorage.h:175
int WINAPI lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:18
smooth NULL
Definition: ftsmooth.c:416
static const char * strw(LPCWSTR x)
Definition: actctx.c:49

Referenced by r_verify_pidl().

◆ test_BindToObject()

static void test_BindToObject ( void  )
static

Definition at line 416 of file shlfolder.c.

417 {
418  HRESULT hr;
419  UINT cChars;
420  IShellFolder *psfDesktop, *psfChild, *psfMyComputer, *psfSystemDir;
421  SHITEMID emptyitem = { 0, { 0 } };
422  LPITEMIDLIST pidlMyComputer, pidlSystemDir, pidl, pidlEmpty = (LPITEMIDLIST)&emptyitem;
423  WCHAR wszSystemDir[MAX_PATH];
424  char szSystemDir[MAX_PATH];
425  char buf[MAX_PATH];
428  HANDLE hfile;
429  WCHAR wszMyComputer[] = {
430  ':',':','{','2','0','D','0','4','F','E','0','-','3','A','E','A','-','1','0','6','9','-',
431  'A','2','D','8','-','0','8','0','0','2','B','3','0','3','0','9','D','}',0 };
432  static const CHAR filename_html[] = "winetest.html";
433  static const CHAR filename_txt[] = "winetest.txt";
434  static const CHAR filename_foo[] = "winetest.foo";
435 
436  /* The following tests shows that BindToObject should fail with E_INVALIDARG if called
437  * with an empty pidl. This is tested for Desktop, MyComputer and the FS ShellFolder
438  */
439  hr = SHGetDesktopFolder(&psfDesktop);
440  ok (hr == S_OK, "SHGetDesktopFolder failed! hr = %08x\n", hr);
441  if (hr != S_OK) return;
442 
443  hr = IShellFolder_BindToObject(psfDesktop, pidlEmpty, NULL, &IID_IShellFolder, (LPVOID*)&psfChild);
444  ok (hr == E_INVALIDARG, "Desktop's BindToObject should fail, when called with empty pidl! hr = %08x\n", hr);
445 
446  hr = IShellFolder_BindToObject(psfDesktop, NULL, NULL, &IID_IShellFolder, (LPVOID*)&psfChild);
447  ok (hr == E_INVALIDARG, "Desktop's BindToObject should fail, when called with NULL pidl! hr = %08x\n", hr);
448 
449  hr = IShellFolder_ParseDisplayName(psfDesktop, NULL, NULL, wszMyComputer, NULL, &pidlMyComputer, NULL);
450  ok (hr == S_OK, "Desktop's ParseDisplayName failed to parse MyComputer's CLSID! hr = %08x\n", hr);
451  if (hr != S_OK) {
452  IShellFolder_Release(psfDesktop);
453  return;
454  }
455 
456  hr = IShellFolder_BindToObject(psfDesktop, pidlMyComputer, NULL, &IID_IShellFolder, (LPVOID*)&psfMyComputer);
457  ok (hr == S_OK, "Desktop failed to bind to MyComputer object! hr = %08x\n", hr);
458  IShellFolder_Release(psfDesktop);
459  IMalloc_Free(ppM, pidlMyComputer);
460  if (hr != S_OK) return;
461 
462  hr = IShellFolder_BindToObject(psfMyComputer, pidlEmpty, NULL, &IID_IShellFolder, (LPVOID*)&psfChild);
463  ok (hr == E_INVALIDARG, "MyComputers's BindToObject should fail, when called with empty pidl! hr = %08x\n", hr);
464 
465  hr = IShellFolder_BindToObject(psfMyComputer, NULL, NULL, &IID_IShellFolder, (LPVOID*)&psfChild);
466  ok (hr == E_INVALIDARG, "MyComputers's BindToObject should fail, when called with NULL pidl! hr = %08x\n", hr);
467 
468  cChars = GetSystemDirectoryA(szSystemDir, MAX_PATH);
469  ok (cChars > 0 && cChars < MAX_PATH, "GetSystemDirectoryA failed! LastError: %u\n", GetLastError());
470  if (cChars == 0 || cChars >= MAX_PATH) {
471  IShellFolder_Release(psfMyComputer);
472  return;
473  }
474  MultiByteToWideChar(CP_ACP, 0, szSystemDir, -1, wszSystemDir, MAX_PATH);
475 
476  hr = IShellFolder_ParseDisplayName(psfMyComputer, NULL, NULL, wszSystemDir, NULL, &pidlSystemDir, NULL);
477  ok (hr == S_OK, "MyComputers's ParseDisplayName failed to parse the SystemDirectory! hr = %08x\n", hr);
478  if (hr != S_OK) {
479  IShellFolder_Release(psfMyComputer);
480  return;
481  }
482 
483  hr = IShellFolder_BindToObject(psfMyComputer, pidlSystemDir, NULL, &IID_IShellFolder, (LPVOID*)&psfSystemDir);
484  ok (hr == S_OK, "MyComputer failed to bind to a FileSystem ShellFolder! hr = %08x\n", hr);
485  IShellFolder_Release(psfMyComputer);
486  IMalloc_Free(ppM, pidlSystemDir);
487  if (hr != S_OK) return;
488 
489  hr = IShellFolder_BindToObject(psfSystemDir, pidlEmpty, NULL, &IID_IShellFolder, (LPVOID*)&psfChild);
490  ok (hr == E_INVALIDARG,
491  "FileSystem ShellFolder's BindToObject should fail, when called with empty pidl! hr = %08x\n", hr);
492 
493  hr = IShellFolder_BindToObject(psfSystemDir, NULL, NULL, &IID_IShellFolder, (LPVOID*)&psfChild);
494  ok (hr == E_INVALIDARG,
495  "FileSystem ShellFolder's BindToObject should fail, when called with NULL pidl! hr = %08x\n", hr);
496 
497  IShellFolder_Release(psfSystemDir);
498 
500  if(!cChars)
501  {
502  skip("Failed to get current directory, skipping tests.\n");
503  return;
504  }
505  if(buf[cChars-1] != '\\') lstrcatA(buf, "\\");
506 
507  SHGetDesktopFolder(&psfDesktop);
508 
509  /* Attempt BindToObject on files. */
510 
511  /* .html */
512  lstrcpyA(pathA, buf);
513  lstrcatA(pathA, filename_html);
515  if(hfile != INVALID_HANDLE_VALUE)
516  {
517  CloseHandle(hfile);
519  hr = IShellFolder_ParseDisplayName(psfDesktop, NULL, NULL, path, NULL, &pidl, NULL);
520  ok(hr == S_OK, "Got 0x%08x\n", hr);
521  if(SUCCEEDED(hr))
522  {
523  hr = IShellFolder_BindToObject(psfDesktop, pidl, NULL, &IID_IShellFolder, (void**)&psfChild);
524  ok(hr == S_OK ||
525  hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), /* XP, W2K3 */
526  "Got 0x%08x\n", hr);
527  if(SUCCEEDED(hr))
528  {
529  IPersist *pp;
530  hr = IShellFolder_QueryInterface(psfChild, &IID_IPersist, (void**)&pp);
531  ok(hr == S_OK, "Got 0x%08x\n", hr);
532  if(SUCCEEDED(hr))
533  {
534  CLSID id;
535  hr = IPersist_GetClassID(pp, &id);
536  ok(hr == S_OK, "Got 0x%08x\n", hr);
537  ok(IsEqualIID(&id, &CLSID_ShellDocObjView), "Unexpected classid %s\n", wine_dbgstr_guid(&id));
538  IPersist_Release(pp);
539  }
540 
541  IShellFolder_Release(psfChild);
542  }
543  ILFree(pidl);
544  }
546  }
547  else
548  win_skip("Failed to create .html testfile.\n");
549 
550  /* .txt */
551  lstrcpyA(pathA, buf);
552  lstrcatA(pathA, filename_txt);
554  if(hfile != INVALID_HANDLE_VALUE)
555  {
556  CloseHandle(hfile);
558  hr = IShellFolder_ParseDisplayName(psfDesktop, NULL, NULL, path, NULL, &pidl, NULL);
559  ok(hr == S_OK, "Got 0x%08x\n", hr);
560  if(SUCCEEDED(hr))
561  {
562  hr = IShellFolder_BindToObject(psfDesktop, pidl, NULL, &IID_IShellFolder, (void**)&psfChild);
563  ok(hr == E_FAIL || /* Vista+ */
564  hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), /* XP, W2K3 */
565  "Got 0x%08x\n", hr);
566  if(SUCCEEDED(hr)) IShellFolder_Release(psfChild);
567  ILFree(pidl);
568  }
570  }
571  else
572  win_skip("Failed to create .txt testfile.\n");
573 
574  /* .foo */
575  lstrcpyA(pathA, buf);
576  lstrcatA(pathA, filename_foo);
578  if(hfile != INVALID_HANDLE_VALUE)
579  {
580  CloseHandle(hfile);
582  hr = IShellFolder_ParseDisplayName(psfDesktop, NULL, NULL, path, NULL, &pidl, NULL);
583  ok(hr == S_OK, "Got 0x%08x\n", hr);
584  if(SUCCEEDED(hr))
585  {
586  hr = IShellFolder_BindToObject(psfDesktop, pidl, NULL, &IID_IShellFolder, (void**)&psfChild);
587  ok(hr == E_FAIL || /* Vista+ */
588  hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), /* XP, W2K3 */
589  "Got 0x%08x\n", hr);
590  if(SUCCEEDED(hr)) IShellFolder_Release(psfChild);
591  ILFree(pidl);
592  }
594  }
595  else
596  win_skip("Failed to create .foo testfile.\n");
597 
598  /* And on the desktop */
600  lstrcatA(pathA, "\\");
601  lstrcatA(pathA, filename_html);
603 
604  CloseHandle(hfile);
606  hr = IShellFolder_ParseDisplayName(psfDesktop, NULL, NULL, path, NULL, &pidl, NULL);
607  ok(hr == S_OK, "Got 0x%08x\n", hr);
608 
609  hr = IShellFolder_BindToObject(psfDesktop, pidl, NULL, &IID_IShellFolder, (void **)&psfChild);
610  ok(hr == S_OK ||
611  hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), /* XP, W2K3 */
612  "Got 0x%08x\n", hr);
613  if(SUCCEEDED(hr)) IShellFolder_Release(psfChild);
614  ILFree(pidl);
615  if(!DeleteFileA(pathA))
616  trace("Failed to delete: %d\n", GetLastError());
617 
619  lstrcatA(pathA, "\\");
620  lstrcatA(pathA, filename_foo);
622 
623  CloseHandle(hfile);
625  hr = IShellFolder_ParseDisplayName(psfDesktop, NULL, NULL, path, NULL, &pidl, NULL);
626  ok(hr == S_OK, "Got 0x%08x\n", hr);
627 
628  hr = IShellFolder_BindToObject(psfDesktop, pidl, NULL, &IID_IShellFolder, (void **)&psfChild);
629  ok(hr == E_FAIL || /* Vista+ */
630  hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), /* XP, W2K3 */
631  "Got 0x%08x\n", hr);
632  if(SUCCEEDED(hr)) IShellFolder_Release(psfChild);
633  ILFree(pidl);
635 
636  IShellFolder_Release(psfDesktop);
637 }
#define trace(...)
Definition: kmt_test.h:217
#define CloseHandle
Definition: compat.h:398
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:925
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
HRESULT hr
Definition: shlfolder.c:183
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define CSIDL_DESKTOP
Definition: shlobj.h:2003
#define CP_ACP
Definition: compat.h:99
const GUID IID_IPersist
Definition: proxy.cpp:14
char CHAR
Definition: xmlstorage.h:175
UINT WINAPI GetSystemDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2282
const char * wine_dbgstr_guid(const GUID *guid)
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define E_FAIL
Definition: ddrawi.h:102
BOOL WINAPI SHGetSpecialFolderPathA(HWND hwndOwner, LPSTR szPath, int nFolder, BOOL bCreate)
Definition: shellpath.c:2553
#define GENERIC_WRITE
Definition: nt_native.h:90
#define ok(value,...)
#define pp
Definition: hlsl.yy.c:978
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
static SCRIPT_CACHE SCRIPT_ANALYSIS OPENTYPE_TAG OPENTYPE_TAG int TEXTRANGE_PROPERTIES int const WCHAR int cChars
Definition: usp10.c:64
LPSTR WINAPI lstrcatA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:123
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define MAX_PATH
Definition: compat.h:26
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
#define S_OK
Definition: intsafe.h:59
#define CREATE_ALWAYS
Definition: disk.h:72
DWORD WINAPI GetCurrentDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2145
Definition: services.c:325
unsigned int UINT
Definition: ndis.h:50
static IMalloc * ppM
Definition: shlfolder.c:47
#define MultiByteToWideChar
Definition: compat.h:100
#define skip(...)
GLenum GLuint id
Definition: glext.h:5579
GLuint pathA
Definition: glext.h:11719
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:399
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
#define win_skip
Definition: test.h:141
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:90
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by START_TEST().

◆ test_CallForAttributes()

static void test_CallForAttributes ( void  )
static

Definition at line 806 of file shlfolder.c.

807 {
808  HKEY hKey;
809  LONG lResult;
810  HRESULT hr;
811  DWORD dwSize;
812  LPSHELLFOLDER psfDesktop;
813  LPITEMIDLIST pidlMyDocuments;
814  DWORD dwAttributes, dwCallForAttributes, dwOrigAttributes, dwOrigCallForAttributes;
815  static const WCHAR wszAttributes[] = { 'A','t','t','r','i','b','u','t','e','s',0 };
816  static const WCHAR wszCallForAttributes[] = {
817  'C','a','l','l','F','o','r','A','t','t','r','i','b','u','t','e','s',0 };
818  static const WCHAR wszMyDocumentsKey[] = {
819  'C','L','S','I','D','\\','{','4','5','0','D','8','F','B','A','-','A','D','2','5','-',
820  '1','1','D','0','-','9','8','A','8','-','0','8','0','0','3','6','1','B','1','1','0','3','}',
821  '\\','S','h','e','l','l','F','o','l','d','e','r',0 };
822  WCHAR wszMyDocuments[] = {
823  ':',':','{','4','5','0','D','8','F','B','A','-','A','D','2','5','-','1','1','D','0','-',
824  '9','8','A','8','-','0','8','0','0','3','6','1','B','1','1','0','3','}',0 };
825 
826  /* For the root of a namespace extension, the attributes are not queried by binding
827  * to the object and calling GetAttributesOf. Instead, the attributes are read from
828  * the registry value HKCR/CLSID/{...}/ShellFolder/Attributes. This is documented on MSDN.
829  *
830  * The MyDocuments shellfolder on WinXP has a HKCR/CLSID/{...}/ShellFolder/CallForAttributes
831  * value. It seems that if the folder is queried for one of the flags set in CallForAttributes,
832  * the shell does bind to the folder object and calls GetAttributesOf. This is not documented
833  * on MSDN. This test is meant to document the observed behaviour on WinXP SP2.
834  */
835  hr = SHGetDesktopFolder(&psfDesktop);
836  ok (hr == S_OK, "SHGetDesktopFolder failed! hr = %08x\n", hr);
837  if (hr != S_OK) return;
838 
839  hr = IShellFolder_ParseDisplayName(psfDesktop, NULL, NULL, wszMyDocuments, NULL,
840  &pidlMyDocuments, NULL);
841  ok (hr == S_OK,
842  "Desktop's ParseDisplayName failed to parse MyDocuments's CLSID! hr = %08x\n", hr);
843  if (hr != S_OK) {
844  IShellFolder_Release(psfDesktop);
845  return;
846  }
847 
848  dwAttributes = 0xffffffff;
849  hr = IShellFolder_GetAttributesOf(psfDesktop, 1,
850  (LPCITEMIDLIST*)&pidlMyDocuments, &dwAttributes);
851  ok (hr == S_OK, "Desktop->GetAttributesOf(MyDocuments) failed! hr = %08x\n", hr);
852 
853  /* We need the following setup (as observed on WinXP SP2), for the tests to make sense. */
854  ok (dwAttributes & SFGAO_FILESYSTEM, "SFGAO_FILESYSTEM attribute is not set for MyDocuments!\n");
855  ok (!(dwAttributes & SFGAO_ISSLOW), "SFGAO_ISSLOW attribute is set for MyDocuments!\n");
856  ok (!(dwAttributes & SFGAO_GHOSTED), "SFGAO_GHOSTED attribute is set for MyDocuments!\n");
857 
858  /* We don't have the MyDocuments shellfolder in wine yet, and thus we don't have the registry
859  * key. So the test will return at this point, if run on wine.
860  */
861  lResult = RegOpenKeyExW(HKEY_CLASSES_ROOT, wszMyDocumentsKey, 0, KEY_WRITE|KEY_READ, &hKey);
862  ok (lResult == ERROR_SUCCESS ||
863  lResult == ERROR_ACCESS_DENIED,
864  "RegOpenKeyEx failed! result: %08x\n", lResult);
865  if (lResult != ERROR_SUCCESS) {
866  if (lResult == ERROR_ACCESS_DENIED)
867  skip("Not enough rights to open the registry key\n");
868  IMalloc_Free(ppM, pidlMyDocuments);
869  IShellFolder_Release(psfDesktop);
870  return;
871  }
872 
873  /* Query MyDocuments' Attributes value, to be able to restore it later. */
874  dwSize = sizeof(DWORD);
875  lResult = RegQueryValueExW(hKey, wszAttributes, NULL, NULL, (LPBYTE)&dwOrigAttributes, &dwSize);
876  ok (lResult == ERROR_SUCCESS, "RegQueryValueEx failed! result: %08x\n", lResult);
877  if (lResult != ERROR_SUCCESS) {
878  RegCloseKey(hKey);
879  IMalloc_Free(ppM, pidlMyDocuments);
880  IShellFolder_Release(psfDesktop);
881  return;
882  }
883 
884  /* Query MyDocuments' CallForAttributes value, to be able to restore it later. */
885  dwSize = sizeof(DWORD);
886  lResult = RegQueryValueExW(hKey, wszCallForAttributes, NULL, NULL,
887  (LPBYTE)&dwOrigCallForAttributes, &dwSize);
888  ok (lResult == ERROR_SUCCESS, "RegQueryValueEx failed! result: %08x\n", lResult);
889  if (lResult != ERROR_SUCCESS) {
890  RegCloseKey(hKey);
891  IMalloc_Free(ppM, pidlMyDocuments);
892  IShellFolder_Release(psfDesktop);
893  return;
894  }
895 
896  /* Define via the Attributes value that MyDocuments attributes are SFGAO_ISSLOW and
897  * SFGAO_GHOSTED and that MyDocuments should be called for the SFGAO_ISSLOW and
898  * SFGAO_FILESYSTEM attributes. */
899  dwAttributes = SFGAO_ISSLOW|SFGAO_GHOSTED;
900  RegSetValueExW(hKey, wszAttributes, 0, REG_DWORD, (LPBYTE)&dwAttributes, sizeof(DWORD));
901  dwCallForAttributes = SFGAO_ISSLOW|SFGAO_FILESYSTEM;
902  RegSetValueExW(hKey, wszCallForAttributes, 0, REG_DWORD,
903  (LPBYTE)&dwCallForAttributes, sizeof(DWORD));
904 
905  /* Although it is not set in CallForAttributes, the SFGAO_GHOSTED flag is reset by
906  * GetAttributesOf. It seems that once there is a single attribute queried, for which
907  * CallForAttributes is set, all flags are taken from the GetAttributesOf call and
908  * the flags in Attributes are ignored.
909  */
910  dwAttributes = SFGAO_ISSLOW|SFGAO_GHOSTED|SFGAO_FILESYSTEM;
911  hr = IShellFolder_GetAttributesOf(psfDesktop, 1,
912  (LPCITEMIDLIST*)&pidlMyDocuments, &dwAttributes);
913  ok (hr == S_OK, "Desktop->GetAttributesOf(MyDocuments) failed! hr = %08x\n", hr);
914  if (hr == S_OK)
915  ok (dwAttributes == SFGAO_FILESYSTEM,
916  "Desktop->GetAttributes(MyDocuments) returned unexpected attributes: %08x\n",
917  dwAttributes);
918 
919  /* Restore MyDocuments' original Attributes and CallForAttributes registry values */
920  RegSetValueExW(hKey, wszAttributes, 0, REG_DWORD, (LPBYTE)&dwOrigAttributes, sizeof(DWORD));
921  RegSetValueExW(hKey, wszCallForAttributes, 0, REG_DWORD,
922  (LPBYTE)&dwOrigCallForAttributes, sizeof(DWORD));
923  RegCloseKey(hKey);
924  IMalloc_Free(ppM, pidlMyDocuments);
925  IShellFolder_Release(psfDesktop);
926 }
#define ERROR_SUCCESS
Definition: deptool.c:10
HRESULT hr
Definition: shlfolder.c:183
#define KEY_READ
Definition: nt_native.h:1023
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
DWORD dwAttributes
Definition: vdmdbg.h:34
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
#define ERROR_ACCESS_DENIED
Definition: compat.h:87
long LONG
Definition: pedump.c:60
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
static IBindCtx void **static IBindCtx void **static DWORD
Definition: shlfolder.c:52
#define KEY_WRITE
Definition: nt_native.h:1031
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4917
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4134
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
#define S_OK
Definition: intsafe.h:59
static IMalloc * ppM
Definition: shlfolder.c:47
#define skip(...)
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define REG_DWORD
Definition: sdbapi.c:596
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54

Referenced by START_TEST().

◆ test_contextmenu()

static void test_contextmenu ( IContextMenu menu,
BOOL  background 
)
static

Definition at line 4397 of file shlfolder.c.

4398 {
4400  const int id_upper_limit = 32767;
4401  const int baseItem = 0x40;
4402  INT max_id, max_id_check;
4403  UINT count, i;
4404  HRESULT hr;
4405 
4406  test_contextmenu_qi(menu, FALSE);
4407 
4408  hr = IContextMenu_QueryContextMenu(menu, hmenu, 0, baseItem, id_upper_limit, CMF_NORMAL);
4409  ok(SUCCEEDED(hr), "Failed to query the menu, hr %#x.\n", hr);
4410 
4411  max_id = HRESULT_CODE(hr) - 1; /* returns max_id + 1 */
4412  ok(max_id <= id_upper_limit, "Got %d\n", max_id);
4414  ok(count, "Got %d\n", count);
4415 
4416  max_id_check = 0;
4417  for (i = 0; i < count; i++)
4418  {
4419  MENUITEMINFOA mii;
4420  INT res;
4421  char buf[255], buf2[255];
4422  ZeroMemory(&mii, sizeof(MENUITEMINFOA));
4423  mii.cbSize = sizeof(MENUITEMINFOA);
4424  mii.fMask = MIIM_ID | MIIM_FTYPE | MIIM_STRING;
4425  mii.dwTypeData = buf2;
4426  mii.cch = sizeof(buf2);
4427 
4428  res = GetMenuItemInfoA(hmenu, i, TRUE, &mii);
4429  ok(res, "Failed to get menu item info, error %d.\n", GetLastError());
4430 
4431  ok((mii.wID <= id_upper_limit) || (mii.fType & MFT_SEPARATOR),
4432  "Got non-separator ID out of range: %d (type: %x)\n", mii.wID, mii.fType);
4433  if (!(mii.fType & MFT_SEPARATOR))
4434  {
4435  max_id_check = (mii.wID > max_id_check) ? mii.wID : max_id_check;
4436  hr = IContextMenu_GetCommandString(menu, mii.wID - baseItem, GCS_VERBA, 0, buf, sizeof(buf));
4437  todo_wine_if(background)
4438  ok(SUCCEEDED(hr) || hr == E_NOTIMPL, "for id 0x%x got 0x%08x (menustr: %s)\n", mii.wID - baseItem, hr, mii.dwTypeData);
4439  if (SUCCEEDED(hr))
4440  trace("for id 0x%x got string %s (menu string: %s)\n", mii.wID - baseItem, buf, mii.dwTypeData);
4441  else if (hr == E_NOTIMPL)
4442  trace("for id 0x%x got E_NOTIMPL (menu string: %s)\n", mii.wID - baseItem, mii.dwTypeData);
4443  }
4444  }
4445  max_id_check -= baseItem;
4446  ok((max_id_check == max_id) ||
4447  (max_id_check == max_id-1) || /* Win 7 */
4448  (max_id_check == max_id-2) || /* Win 8 */
4449  (max_id_check == max_id-3),
4450  "Not equal (or near equal), got %d and %d\n", max_id_check, max_id);
4451 
4452  if (count)
4453  {
4454  CMINVOKECOMMANDINFO cmi;
4455 
4456  memset(&cmi, 0, sizeof(CMINVOKECOMMANDINFO));
4457  cmi.cbSize = sizeof(CMINVOKECOMMANDINFO);
4458 
4459  /* Attempt to execute a nonexistent command */
4460  cmi.lpVerb = MAKEINTRESOURCEA(9999);
4461  hr = IContextMenu_InvokeCommand(menu, &cmi);
4462  todo_wine_if(background)
4463  ok(hr == E_INVALIDARG, "Got 0x%08x\n", hr);
4464 
4465  cmi.lpVerb = "foobar_wine_test";
4466  hr = IContextMenu_InvokeCommand(menu, &cmi);
4467  todo_wine_if(background)
4468  ok((hr == E_INVALIDARG) || (hr == E_FAIL /* Win7 */) ||
4469  (hr == HRESULT_FROM_WIN32(ERROR_NO_ASSOCIATION) /* Vista */),
4470  "Unexpected hr %#x.\n", hr);
4471  }
4472 
4473  DestroyMenu(hmenu);
4474 }
#define trace(...)
Definition: kmt_test.h:217
#define MIIM_FTYPE
Definition: winuser.h:724
#define TRUE
Definition: types.h:120
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
HRESULT hr
Definition: shlfolder.c:183
static HMENU hmenu
Definition: win.c:66
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLuint GLuint GLsizei count
Definition: gl.h:1545
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define ZeroMemory
Definition: winbase.h:1635
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581
#define E_FAIL
Definition: ddrawi.h:102
int32_t INT
Definition: typedefs.h:56
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
int WINAPI GetMenuItemCount(_In_opt_ HMENU)
#define ok(value,...)
#define E_INVALIDARG
Definition: ddrawi.h:101
#define MIIM_ID
Definition: winuser.h:717
#define todo_wine_if(is_todo)
Definition: test.h:155
LONG HRESULT
Definition: typedefs.h:77
BOOL WINAPI GetMenuItemInfoA(_In_ HMENU, _In_ UINT, _In_ BOOL, _Inout_ LPMENUITEMINFOA)
#define MFT_SEPARATOR
Definition: winuser.h:739
BOOL WINAPI DestroyMenu(_In_ HMENU)
#define MIIM_STRING
Definition: winuser.h:722
#define ERROR_NO_ASSOCIATION
Definition: winerror.h:677
static void test_contextmenu_qi(IContextMenu *menu, BOOL todo)
Definition: shlfolder.c:4379
#define E_NOTIMPL
Definition: ddrawi.h:99
unsigned int UINT
Definition: ndis.h:50
HMENU WINAPI CreatePopupMenu(void)
Definition: menu.c:846
struct tagMENUITEMINFOA MENUITEMINFOA
#define HRESULT_CODE(hr)
Definition: winerror.h:76
GLuint res
Definition: glext.h:9613
#define memset(x, y, z)
Definition: compat.h:39
LPSTR dwTypeData
Definition: winuser.h:3193
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by test_GetUIObject().

◆ test_contextmenu_qi()

static void test_contextmenu_qi ( IContextMenu menu,
BOOL  todo 
)
static

Definition at line 4379 of file shlfolder.c.

4380 {
4381  IUnknown *unk;
4382  HRESULT hr;
4383 
4384  hr = IContextMenu_QueryInterface(menu, &IID_IShellExtInit, (void **)&unk);
4386  ok(hr == S_OK, "Failed to get IShellExtInit, hr %#x.\n", hr);
4387 if (hr == S_OK)
4388  IUnknown_Release(unk);
4389 
4390  hr = IContextMenu_QueryInterface(menu, &IID_IObjectWithSite, (void **)&unk);
4392  ok(hr == S_OK, "Failed to get IShellExtInit, hr %#x.\n", hr);
4393 if (hr == S_OK)
4394  IUnknown_Release(unk);
4395 }
HRESULT hr
Definition: shlfolder.c:183
#define ok(value,...)
int todo
Definition: shlfolder.c:184
#define todo_wine_if(is_todo)
Definition: test.h:155
LONG HRESULT
Definition: typedefs.h:77
const IID IID_IObjectWithSite
#define S_OK
Definition: intsafe.h:59

Referenced by test_contextmenu(), and test_SHCreateDefaultContextMenu().

◆ test_DataObject()

static void test_DataObject ( void  )
static

Definition at line 5100 of file shlfolder.c.

5101 {
5102  IShellFolder *desktop;
5103  IDataObject *data_obj;
5104  HRESULT hres;
5105  IEnumIDList *peidl;
5106  LPITEMIDLIST apidl;
5107  FORMATETC fmt;
5108  DWORD cf_shellidlist;
5109  STGMEDIUM medium;
5110 
5111  SHGetDesktopFolder(&desktop);
5112 
5113  hres = IShellFolder_EnumObjects(desktop, NULL,
5114  SHCONTF_NONFOLDERS|SHCONTF_FOLDERS|SHCONTF_INCLUDEHIDDEN, &peidl);
5115  ok(hres == S_OK, "got %x\n", hres);
5116 
5117  if(IEnumIDList_Next(peidl, 1, &apidl, NULL) != S_OK) {
5118  skip("no files on desktop - skipping GetDataObject tests\n");
5119  IEnumIDList_Release(peidl);
5120  IShellFolder_Release(desktop);
5121  return;
5122  }
5123  IEnumIDList_Release(peidl);
5124 
5125  hres = IShellFolder_GetUIObjectOf(desktop, NULL, 1, (LPCITEMIDLIST*)&apidl,
5126  &IID_IDataObject, NULL, (void**)&data_obj);
5127  ok(hres == S_OK, "got %x\n", hres);
5128  ILFree(apidl);
5129  IShellFolder_Release(desktop);
5130 
5131  cf_shellidlist = RegisterClipboardFormatW(CFSTR_SHELLIDLISTW);
5132  fmt.cfFormat = cf_shellidlist;
5133  fmt.ptd = NULL;
5134  fmt.dwAspect = DVASPECT_CONTENT;
5135  fmt.lindex = -1;
5136  fmt.tymed = TYMED_HGLOBAL;
5137  hres = IDataObject_QueryGetData(data_obj, &fmt);
5138  ok(hres == S_OK, "got %x\n", hres);
5139 
5140  fmt.tymed = TYMED_HGLOBAL | TYMED_ISTREAM;
5141  hres = IDataObject_QueryGetData(data_obj, &fmt);
5142  ok(hres == S_OK, "got %x\n", hres);
5143 
5144  fmt.tymed = TYMED_ISTREAM;
5145  hres = IDataObject_QueryGetData(data_obj, &fmt);
5146  todo_wine ok(hres == S_FALSE, "got %x\n", hres);
5147 
5148  fmt.tymed = TYMED_HGLOBAL | TYMED_ISTREAM;
5149  hres = IDataObject_GetData(data_obj, &fmt, &medium);
5150  ok(hres == S_OK, "got %x\n", hres);
5151  ok(medium.tymed == TYMED_HGLOBAL, "medium.tymed = %x\n", medium.tymed);
5152  ReleaseStgMedium(&medium);
5153 
5154  IDataObject_Release(data_obj);
5155 }
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:925
void WINAPI ReleaseStgMedium(STGMEDIUM *pmedium)
Definition: ole2.c:2036
UINT WINAPI RegisterClipboardFormatW(_In_ LPCWSTR)
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
const char * fmt
Definition: wsprintf.c:30
const GUID IID_IDataObject
#define ok(value,...)
#define S_FALSE
Definition: winerror.h:2357
static const WCHAR CFSTR_SHELLIDLISTW[]
Definition: shlobj.h:425
smooth NULL
Definition: ftsmooth.c:416
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
#define todo_wine
Definition: test.h:154
#define S_OK
Definition: intsafe.h:59
#define skip(...)
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
Definition: dsound.c:943

Referenced by START_TEST().

◆ test_desktop_IPersist()

static void test_desktop_IPersist ( void  )
static

Definition at line 4323 of file shlfolder.c.

4324 {
4325  IShellFolder *desktop;
4326  IPersist *persist;
4327  IPersistFolder2 *ppf2;
4328  CLSID clsid;
4329  HRESULT hr;
4330 
4331  hr = SHGetDesktopFolder(&desktop);
4332  ok(hr == S_OK, "failed %08x\n", hr);
4333 
4334  hr = IShellFolder_QueryInterface(desktop, &IID_IPersist, (void**)&persist);
4335  ok(hr == S_OK, "failed %08x\n", hr);
4336 
4337  if (hr == S_OK)
4338  {
4339  if (0)
4340  {
4341  /* crashes on native */
4342  IPersist_GetClassID(persist, NULL);
4343  }
4344  memset(&clsid, 0, sizeof(clsid));
4345  hr = IPersist_GetClassID(persist, &clsid);
4346  ok(hr == S_OK, "failed %08x\n", hr);
4347  ok(IsEqualIID(&CLSID_ShellDesktop, &clsid), "Expected CLSID_ShellDesktop\n");
4348  IPersist_Release(persist);
4349  }
4350 
4351  hr = IShellFolder_QueryInterface(desktop, &IID_IPersistFolder2, (void**)&ppf2);
4352  ok(hr == S_OK || broken(hr == E_NOINTERFACE) /* pre-Vista */, "failed %08x\n", hr);
4353  if(SUCCEEDED(hr))
4354  {
4355  IPersistFolder *ppf;
4356  LPITEMIDLIST pidl;
4357  hr = IShellFolder_QueryInterface(desktop, &IID_IPersistFolder, (void**)&ppf);
4358  ok(hr == S_OK, "IID_IPersistFolder2 without IID_IPersistFolder.\n");
4359  if(SUCCEEDED(hr))
4360  IPersistFolder_Release(ppf);
4361 
4362  todo_wine {
4363  hr = IPersistFolder2_Initialize(ppf2, NULL);
4364  ok(hr == S_OK, "got %08x\n", hr);
4365  }
4366 
4367  pidl = NULL;
4368  hr = IPersistFolder2_GetCurFolder(ppf2, &pidl);
4369  ok(hr == S_OK, "got %08x\n", hr);
4370  ok(pidl != NULL, "pidl was NULL.\n");
4371  if(SUCCEEDED(hr)) ILFree(pidl);
4372 
4373  IPersistFolder2_Release(ppf2);
4374  }
4375 
4376  IShellFolder_Release(desktop);
4377 }
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:925
#define E_NOINTERFACE
Definition: winerror.h:2364
HRESULT hr
Definition: shlfolder.c:183
const GUID IID_IPersist
Definition: proxy.cpp:14
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
LONG HRESULT
Definition: typedefs.h:77
REFCLSID clsid
Definition: msctf.c:84
#define todo_wine
Definition: test.h:154
#define broken(x)
Definition: _sntprintf.h:21
#define S_OK
Definition: intsafe.h:59
#define memset(x, y, z)
Definition: compat.h:39
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:90
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by START_TEST().

◆ test_EnumObjects()

static void test_EnumObjects ( IShellFolder iFolder)
static

Definition at line 321 of file shlfolder.c.

322 {
323  IEnumIDList *iEnumList;
324  LPITEMIDLIST newPIDL, idlArr[10];
325  ULONG NumPIDLs;
326  int i=0, j;
327  HRESULT hr;
328 
329  static const WORD iResults [5][5] =
330  {
331  { 0,-1,-1,-1,-1},
332  { 1, 0,-1,-1,-1},
333  { 1, 1, 0,-1,-1},
334  { 1, 1, 1, 0,-1},
335  { 1, 1, 1, 1, 0}
336  };
337 
338 #define SFGAO_testfor SFGAO_FILESYSTEM | SFGAO_FOLDER | SFGAO_FILESYSANCESTOR | SFGAO_CAPABILITYMASK
339  /* Don't test for SFGAO_HASSUBFOLDER since we return real state and native cached */
340  static const ULONG attrs[5] =
341  {
342  SFGAO_CAPABILITYMASK | SFGAO_FILESYSTEM | SFGAO_FOLDER | SFGAO_FILESYSANCESTOR,
343  SFGAO_CAPABILITYMASK | SFGAO_FILESYSTEM | SFGAO_FOLDER | SFGAO_FILESYSANCESTOR,
344  SFGAO_CAPABILITYMASK | SFGAO_FILESYSTEM,
345  SFGAO_CAPABILITYMASK | SFGAO_FILESYSTEM,
346  SFGAO_CAPABILITYMASK | SFGAO_FILESYSTEM,
347  };
348  static const ULONG full_attrs[5] =
349  {
350  SFGAO_CAPABILITYMASK | SFGAO_STORAGE | SFGAO_STORAGEANCESTOR | SFGAO_FILESYSTEM | SFGAO_FOLDER | SFGAO_FILESYSANCESTOR,
351  SFGAO_CAPABILITYMASK | SFGAO_STORAGE | SFGAO_STORAGEANCESTOR | SFGAO_FILESYSTEM | SFGAO_FOLDER | SFGAO_FILESYSANCESTOR,
352  SFGAO_CAPABILITYMASK | SFGAO_STREAM | SFGAO_FILESYSTEM,
353  SFGAO_CAPABILITYMASK | SFGAO_STREAM | SFGAO_FILESYSTEM,
354  SFGAO_CAPABILITYMASK | SFGAO_STREAM | SFGAO_FILESYSTEM,
355  };
356 
357  hr = IShellFolder_EnumObjects(iFolder, NULL, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS | SHCONTF_INCLUDEHIDDEN, &iEnumList);
358  ok(hr == S_OK, "EnumObjects failed %08x\n", hr);
359 
360  /* This is to show that, contrary to what is said on MSDN, on IEnumIDList::Next,
361  * the filesystem shellfolders return S_OK even if less than 'celt' items are
362  * returned (in contrast to S_FALSE). We have to do it in a loop since WinXP
363  * only ever returns a single entry per call. */
364  while (IEnumIDList_Next(iEnumList, 10-i, &idlArr[i], &NumPIDLs) == S_OK)
365  i += NumPIDLs;
366  ok (i == 5, "i: %d\n", i);
367 
368  hr = IEnumIDList_Release(iEnumList);
369  ok(hr == S_OK, "IEnumIDList_Release failed %08x\n", hr);
370 
371  /* Sort them first in case of wrong order from system */
372  for (i=0;i<5;i++) for (j=0;j<5;j++)
373  if ((SHORT)IShellFolder_CompareIDs(iFolder, 0, idlArr[i], idlArr[j]) < 0)
374  {
375  newPIDL = idlArr[i];
376  idlArr[i] = idlArr[j];
377  idlArr[j] = newPIDL;
378  }
379 
380  for (i=0;i<5;i++) for (j=0;j<5;j++)
381  {
382  hr = IShellFolder_CompareIDs(iFolder, 0, idlArr[i], idlArr[j]);
383  ok(hr == iResults[i][j], "Got %x expected [%d]-[%d]=%x\n", hr, i, j, iResults[i][j]);
384  }
385 
386 
387  for (i = 0; i < 5; i++)
388  {
389  SFGAOF flags;
390 #define SFGAO_VISTA SFGAO_DROPTARGET | SFGAO_CANLINK | SFGAO_CANCOPY
391  /* Native returns all flags no matter what we ask for */
392  flags = SFGAO_CANCOPY;
393  hr = IShellFolder_GetAttributesOf(iFolder, 1, (LPCITEMIDLIST*)(idlArr + i), &flags);
394  flags &= SFGAO_testfor;
395  ok(hr == S_OK, "GetAttributesOf returns %08x\n", hr);
396  ok(flags == (attrs[i]) ||
397  flags == ((attrs[i] & ~SFGAO_CAPABILITYMASK) | SFGAO_VISTA), /* Vista and higher */
398  "GetAttributesOf[%i] got %08x, expected %08x\n", i, flags, attrs[i]);
399 
401  hr = IShellFolder_GetAttributesOf(iFolder, 1, (LPCITEMIDLIST*)(idlArr + i), &flags);
402  flags &= SFGAO_testfor;
403  ok(hr == S_OK, "GetAttributesOf returns %08x\n", hr);
404  ok(flags == attrs[i], "GetAttributesOf[%i] got %08x, expected %08x\n", i, flags, attrs[i]);
405 
406  flags = ~0u;
407  hr = IShellFolder_GetAttributesOf(iFolder, 1, (LPCITEMIDLIST*)(idlArr + i), &flags);
408  ok(hr == S_OK, "GetAttributesOf returns %08x\n", hr);
409  ok((flags & ~(SFGAO_HASSUBFOLDER|SFGAO_COMPRESSED)) == full_attrs[i], "%d: got %08x expected %08x\n", i, flags, full_attrs[i]);
410  }
411 
412  for (i=0;i<5;i++)
413  IMalloc_Free(ppM, idlArr[i]);
414 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
HRESULT hr
Definition: shlfolder.c:183
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
#define SFGAO_VISTA
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
short SHORT
Definition: pedump.c:59
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
LONG HRESULT
Definition: typedefs.h:77
unsigned short WORD
Definition: ntddk_ex.h:93
GLbitfield flags
Definition: glext.h:7161
#define SFGAO_testfor
#define S_OK
Definition: intsafe.h:59
static IMalloc * ppM
Definition: shlfolder.c:47
unsigned int ULONG
Definition: retypes.h:1
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
static IShellFolder IShellItem **static IBindCtx LPITEMIDLIST SFGAOF
Definition: ebrowser.c:83

Referenced by test_EnumObjects_and_CompareIDs().

◆ test_EnumObjects_and_CompareIDs()

static void test_EnumObjects_and_CompareIDs ( void  )
static

Definition at line 1211 of file shlfolder.c.

1212 {
1213  ITEMIDLIST *newPIDL;
1214  IShellFolder *IDesktopFolder, *testIShellFolder;
1215  char cCurrDirA [MAX_PATH] = {0};
1216  static const CHAR cTestDirA[] = "\\testdir";
1217  WCHAR cTestDirW[MAX_PATH];
1218  int len;
1219  HRESULT hr;
1220 
1221  GetCurrentDirectoryA(MAX_PATH, cCurrDirA);
1222  len = lstrlenA(cCurrDirA);
1223 
1224  if(len == 0) {
1225  win_skip("GetCurrentDirectoryA returned empty string. Skipping test_EnumObjects_and_CompareIDs\n");
1226  return;
1227  }
1228  if(cCurrDirA[len-1] == '\\')
1229  cCurrDirA[len-1] = 0;
1230 
1231  lstrcatA(cCurrDirA, cTestDirA);
1232  MultiByteToWideChar(CP_ACP, 0, cCurrDirA, -1, cTestDirW, MAX_PATH);
1233 
1234  hr = SHGetDesktopFolder(&IDesktopFolder);
1235  ok(hr == S_OK, "SHGetDesktopfolder failed %08x\n", hr);
1236 
1238 
1239  hr = IShellFolder_ParseDisplayName(IDesktopFolder, NULL, NULL, cTestDirW, NULL, &newPIDL, 0);
1240  ok(hr == S_OK, "ParseDisplayName failed %08x\n", hr);
1241 
1242  hr = IShellFolder_BindToObject(IDesktopFolder, newPIDL, NULL, (REFIID)&IID_IShellFolder, (LPVOID *)&testIShellFolder);
1243  ok(hr == S_OK, "BindToObject failed %08x\n", hr);
1244 
1245  test_EnumObjects(testIShellFolder);
1246 
1247  IShellFolder_Release(testIShellFolder);
1248 
1249  Cleanup();
1250 
1251  IMalloc_Free(ppM, newPIDL);
1252 
1253  IShellFolder_Release(IDesktopFolder);
1254 }
static IBindCtx REFIID
Definition: shlfolder.c:50
HRESULT hr
Definition: shlfolder.c:183
#define CP_ACP
Definition: compat.h:99
char CHAR
Definition: xmlstorage.h:175
static void CreateFilesFolders(void)
Definition: shlfolder.c:296
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
LPSTR WINAPI lstrcatA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:123
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define MAX_PATH
Definition: compat.h:26
GLenum GLsizei len
Definition: glext.h:6722
static void test_EnumObjects(IShellFolder *iFolder)
Definition: shlfolder.c:321
#define S_OK
Definition: intsafe.h:59
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
DWORD WINAPI GetCurrentDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2145
static void Cleanup(void)
Definition: shlfolder.c:308
static IMalloc * ppM
Definition: shlfolder.c:47
#define MultiByteToWideChar
Definition: compat.h:100
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test_FolderShortcut()

static void test_FolderShortcut ( void  )
static

Definition at line 1369 of file shlfolder.c.

1369  {
1370  IPersistPropertyBag *pPersistPropertyBag;
1371  IShellFolder *pShellFolder, *pDesktopFolder;
1372  IPersistFolder3 *pPersistFolder3;
1373  HRESULT hr;
1374  STRRET strret;
1375  WCHAR wszDesktopPath[MAX_PATH], wszBuffer[MAX_PATH];
1376  BOOL result;
1377  CLSID clsid;
1378  LPITEMIDLIST pidlCurrentFolder, pidlWineTestFolder, pidlSubFolder;
1379  HKEY hShellExtKey;
1380  WCHAR wszWineTestFolder[] = {
1381  ':',':','{','9','B','3','5','2','E','B','F','-','2','7','6','5','-','4','5','C','1','-',
1382  'B','4','C','6','-','8','5','C','C','7','F','7','A','B','C','6','4','}',0 };
1383  WCHAR wszShellExtKey[] = { 'S','o','f','t','w','a','r','e','\\',
1384  'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\',
1385  'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
1386  'E','x','p','l','o','r','e','r','\\','D','e','s','k','t','o','p','\\',
1387  'N','a','m','e','S','p','a','c','e','\\',
1388  '{','9','b','3','5','2','e','b','f','-','2','7','6','5','-','4','5','c','1','-',
1389  'b','4','c','6','-','8','5','c','c','7','f','7','a','b','c','6','4','}',0 };
1390 
1391  WCHAR wszSomeSubFolder[] = { 'S','u','b','F','o','l','d','e','r', 0};
1392  static const GUID CLSID_UnixDosFolder =
1393  {0x9d20aae8, 0x0625, 0x44b0, {0x9c, 0xa7, 0x71, 0x88, 0x9c, 0x22, 0x54, 0xd9}};
1394 
1395  /* These tests basically show, that CLSID_FolderShortcuts are initialized
1396  * via their IPersistPropertyBag interface. And that the target folder
1397  * is taken from the IPropertyBag's 'Target' property.
1398  */
1399  hr = CoCreateInstance(&CLSID_FolderShortcut, NULL, CLSCTX_INPROC_SERVER,
1400  &IID_IPersistPropertyBag, (LPVOID*)&pPersistPropertyBag);
1401  if (hr == REGDB_E_CLASSNOTREG) {
1402  win_skip("CLSID_FolderShortcut is not implemented\n");
1403  return;
1404  }
1405  ok (hr == S_OK, "CoCreateInstance failed! hr = 0x%08x\n", hr);
1406  if (hr != S_OK) return;
1407 
1408  hr = IPersistPropertyBag_Load(pPersistPropertyBag, &InitPropertyBag, NULL);
1409  ok(hr == S_OK, "IPersistPropertyBag_Load failed! hr = %08x\n", hr);
1410  if (hr != S_OK) {
1411  IPersistPropertyBag_Release(pPersistPropertyBag);
1412  return;
1413  }
1414 
1415  hr = IPersistPropertyBag_QueryInterface(pPersistPropertyBag, &IID_IShellFolder,
1416  (LPVOID*)&pShellFolder);
1417  IPersistPropertyBag_Release(pPersistPropertyBag);
1418  ok(hr == S_OK, "IPersistPropertyBag_QueryInterface(IShellFolder) failed! hr = %08x\n", hr);
1419  if (hr != S_OK) return;
1420 
1421  hr = IShellFolder_GetDisplayNameOf(pShellFolder, NULL, SHGDN_FORPARSING, &strret);
1422  ok(hr == S_OK || broken(hr == E_INVALIDARG) /* win10 */,
1423  "IShellFolder_GetDisplayNameOf(NULL) failed! hr = %08x\n", hr);
1424  if (hr != S_OK) {
1425  IShellFolder_Release(pShellFolder);
1426  return;
1427  }
1428 
1430  ok(result, "SHGetSpecialFolderPathW(CSIDL_DESKTOPDIRECTORY) failed! %u\n", GetLastError());
1431  if (!result) return;
1432 
1433  StrRetToBufW(&strret, NULL, wszBuffer, MAX_PATH);
1434  ok(!lstrcmpiW(wszDesktopPath, wszBuffer), "FolderShortcut returned incorrect folder!\n");
1435 
1436  hr = IShellFolder_QueryInterface(pShellFolder, &IID_IPersistFolder3, (LPVOID*)&pPersistFolder3);
1437  IShellFolder_Release(pShellFolder);
1438  ok(hr == S_OK, "IShellFolder_QueryInterface(IID_IPersistFolder3 failed! hr = 0x%08x\n", hr);
1439  if (hr != S_OK) return;
1440 
1441  hr = IPersistFolder3_GetClassID(pPersistFolder3, &clsid);
1442  ok(hr == S_OK, "IPersistFolder3_GetClassID failed! hr=0x%08x\n", hr);
1443  ok(IsEqualCLSID(&clsid, &CLSID_FolderShortcut), "Unexpected CLSID!\n");
1444 
1445  hr = IPersistFolder3_GetCurFolder(pPersistFolder3, &pidlCurrentFolder);
1446  todo_wine ok(hr == S_FALSE, "IPersistFolder3_GetCurFolder failed! hr=0x%08x\n", hr);
1447  ok(!pidlCurrentFolder, "IPersistFolder3_GetCurFolder should return a NULL pidl!\n");
1448 
1449  /* For FolderShortcut objects, the Initialize method initialized the folder's position in the
1450  * shell namespace. The target folder, read from the property bag above, remains untouched.
1451  * The following tests show this: The itemidlist for some imaginary shellfolder object
1452  * is created and the FolderShortcut is initialized with it. GetCurFolder now returns this
1453  * itemidlist, but GetDisplayNameOf still returns the path from above.
1454  */
1455  hr = SHGetDesktopFolder(&pDesktopFolder);
1456  ok (hr == S_OK, "SHGetDesktopFolder failed! hr = %08x\n", hr);
1457  if (hr != S_OK) return;
1458 
1459  /* Temporarily register WineTestFolder as a shell namespace extension at the Desktop.
1460  * Otherwise ParseDisplayName fails on WinXP with E_INVALIDARG */
1461  RegCreateKeyW(HKEY_CURRENT_USER, wszShellExtKey, &hShellExtKey);
1462  RegCloseKey(hShellExtKey);
1463  hr = IShellFolder_ParseDisplayName(pDesktopFolder, NULL, NULL, wszWineTestFolder, NULL,
1464  &pidlWineTestFolder, NULL);
1465  RegDeleteKeyW(HKEY_CURRENT_USER, wszShellExtKey);
1466  IShellFolder_Release(pDesktopFolder);
1467  ok (hr == S_OK, "IShellFolder::ParseDisplayName failed! hr = %08x\n", hr);
1468  if (hr != S_OK) return;
1469 
1470  hr = IPersistFolder3_Initialize(pPersistFolder3, pidlWineTestFolder);
1471  ok (hr == S_OK, "IPersistFolder3::Initialize failed! hr = %08x\n", hr);
1472  if (hr != S_OK) {
1473  IPersistFolder3_Release(pPersistFolder3);
1474  ILFree(pidlWineTestFolder);
1475  return;
1476  }
1477 
1478  hr = IPersistFolder3_GetCurFolder(pPersistFolder3, &pidlCurrentFolder);
1479  ok(hr == S_OK, "IPersistFolder3_GetCurFolder failed! hr=0x%08x\n", hr);
1480  ok(ILIsEqual(pidlCurrentFolder, pidlWineTestFolder),
1481  "IPersistFolder3_GetCurFolder should return pidlWineTestFolder!\n");
1482  ILFree(pidlCurrentFolder);
1483  ILFree(pidlWineTestFolder);
1484 
1485  hr = IPersistFolder3_QueryInterface(pPersistFolder3, &IID_IShellFolder, (LPVOID*)&pShellFolder);
1486  IPersistFolder3_Release(pPersistFolder3);
1487  ok(hr == S_OK, "IPersistFolder3_QueryInterface(IShellFolder) failed! hr = %08x\n", hr);
1488  if (hr != S_OK) return;
1489 
1490  hr = IShellFolder_GetDisplayNameOf(pShellFolder, NULL, SHGDN_FORPARSING, &strret);
1491  ok(hr == S_OK, "IShellFolder_GetDisplayNameOf(NULL) failed! hr = %08x\n", hr);
1492  if (hr != S_OK) {
1493  IShellFolder_Release(pShellFolder);
1494  return;
1495  }
1496 
1497  StrRetToBufW(&strret, NULL, wszBuffer, MAX_PATH);
1498  ok(!lstrcmpiW(wszDesktopPath, wszBuffer), "FolderShortcut returned incorrect folder!\n");
1499 
1500  /* Next few lines are meant to show that children of FolderShortcuts are not FolderShortcuts,
1501  * but ShellFSFolders. */
1502  myPathAddBackslashW(wszDesktopPath);
1503  lstrcatW(wszDesktopPath, wszSomeSubFolder);
1504  if (!CreateDirectoryW(wszDesktopPath, NULL)) {
1505  IShellFolder_Release(pShellFolder);
1506  return;
1507  }
1508 
1509  hr = IShellFolder_ParseDisplayName(pShellFolder, NULL, NULL, wszSomeSubFolder, NULL,
1510  &pidlSubFolder, NULL);
1511  RemoveDirectoryW(wszDesktopPath);
1512  ok (hr == S_OK, "IShellFolder::ParseDisplayName failed! hr = %08x\n", hr);
1513  if (hr != S_OK) {
1514  IShellFolder_Release(pShellFolder);
1515  return;
1516  }
1517 
1518  hr = IShellFolder_BindToObject(pShellFolder, pidlSubFolder, NULL, &IID_IPersistFolder3,
1519  (LPVOID*)&pPersistFolder3);
1520  IShellFolder_Release(pShellFolder);
1521  ILFree(pidlSubFolder);
1522  ok (hr == S_OK, "IShellFolder::BindToObject failed! hr = %08x\n", hr);
1523  if (hr != S_OK)
1524  return;
1525 
1526  /* On windows, we expect CLSID_ShellFSFolder. On wine we relax this constraint
1527  * a little bit and also allow CLSID_UnixDosFolder. */
1528  hr = IPersistFolder3_GetClassID(pPersistFolder3, &clsid);
1529  ok(hr == S_OK, "IPersistFolder3_GetClassID failed! hr=0x%08x\n", hr);
1530  ok(IsEqualCLSID(&clsid, &CLSID_ShellFSFolder) || IsEqualCLSID(&clsid, &CLSID_UnixDosFolder),
1531  "IPersistFolder3::GetClassID returned unexpected CLSID!\n");
1532 
1533  IPersistFolder3_Release(pPersistFolder3);
1534 }
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:90
const GUID CLSID_UnixDosFolder
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:925
HRESULT hr
Definition: shlfolder.c:183
HRESULT WINAPI StrRetToBufW(LPSTRRET src, const ITEMIDLIST *pidl, LPWSTR dest, UINT len)
Definition: string.c:1522
#define HKEY_CURRENT_USER
Definition: winreg.h:11
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1240
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL WINAPI ILIsEqual(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:535
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned int BOOL
Definition: ntddk_ex.h:94
const GUID IID_IPersistPropertyBag
Definition: proxy.cpp:11
#define ok(value,...)
#define S_FALSE
Definition: winerror.h:2357
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI RemoveDirectoryW(IN LPCWSTR lpPathName)
Definition: dir.c:732
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define MAX_PATH
Definition: compat.h:26
REFCLSID clsid
Definition: msctf.c:84
#define todo_wine
Definition: test.h:154
static LPWSTR myPathAddBackslashW(LPWSTR lpszPath)
Definition: shlfolder.c:161
LONG WINAPI RegCreateKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:1202
#define broken(x)
Definition: _sntprintf.h:21
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3234
#define S_OK
Definition: intsafe.h:59
#define REGDB_E_CLASSNOTREG
Definition: winerror.h:2696
BOOL WINAPI SHGetSpecialFolderPathW(HWND hwndOwner, LPWSTR szPath, int nFolder, BOOL bCreate)
Definition: shellpath.c:2566
#define CSIDL_DESKTOPDIRECTORY
Definition: shlobj.h:2018
static struct IPropertyBag InitPropertyBag
Definition: shlfolder.c:1365
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
GLuint64EXT * result
Definition: glext.h:11304
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
#define IsEqualCLSID(rclsid1, rclsid2)
Definition: guiddef.h:91
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test_GetAttributesOf()

static void test_GetAttributesOf ( void  )
static

Definition at line 928 of file shlfolder.c.

929 {
930  HRESULT hr;
931  LPSHELLFOLDER psfDesktop, psfMyComputer;
932  SHITEMID emptyitem = { 0, { 0 } };
933  LPCITEMIDLIST pidlEmpty = (LPCITEMIDLIST)&emptyitem;
934  LPITEMIDLIST pidlMyComputer;
935  DWORD dwFlags;
936  static const DWORD desktopFlags = SFGAO_STORAGE | SFGAO_HASPROPSHEET | SFGAO_STORAGEANCESTOR |
937  SFGAO_FILESYSANCESTOR | SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_HASSUBFOLDER;
938  static const DWORD myComputerFlags = SFGAO_CANRENAME | SFGAO_CANDELETE | SFGAO_HASPROPSHEET |
939  SFGAO_DROPTARGET | SFGAO_FILESYSANCESTOR | SFGAO_FOLDER | SFGAO_HASSUBFOLDER;
940  WCHAR wszMyComputer[] = {
941  ':',':','{','2','0','D','0','4','F','E','0','-','3','A','E','A','-','1','0','6','9','-',
942  'A','2','D','8','-','0','8','0','0','2','B','3','0','3','0','9','D','}',0 };
943  char cCurrDirA [MAX_PATH] = {0};
944  WCHAR cCurrDirW [MAX_PATH];
945  static WCHAR cTestDirW[] = {'t','e','s','t','d','i','r',0};
946  IShellFolder *IDesktopFolder, *testIShellFolder;
947  ITEMIDLIST *newPIDL;
948  int len;
949 
950  hr = SHGetDesktopFolder(&psfDesktop);
951  ok (hr == S_OK, "SHGetDesktopFolder failed! hr = %08x\n", hr);
952  if (hr != S_OK) return;
953 
954  /* The Desktop attributes can be queried with a single empty itemidlist, .. */
955  dwFlags = 0xffffffff;
956  hr = IShellFolder_GetAttributesOf(psfDesktop, 1, &pidlEmpty, &dwFlags);
957  ok (hr == S_OK, "Desktop->GetAttributesOf(empty pidl) failed! hr = %08x\n", hr);
958  ok (dwFlags == desktopFlags, "Wrong Desktop attributes: %08x\n", dwFlags);
959 
960  /* .. or with no itemidlist at all. */
961  dwFlags = 0xffffffff;
962  hr = IShellFolder_GetAttributesOf(psfDesktop, 0, NULL, &dwFlags);
963  ok (hr == S_OK, "Desktop->GetAttributesOf(NULL) failed! hr = %08x\n", hr);
964  ok (dwFlags == desktopFlags, "Wrong Desktop attributes: %08x\n", dwFlags);
965 
966  /* Testing the attributes of the MyComputer shellfolder */
967  hr = IShellFolder_ParseDisplayName(psfDesktop, NULL, NULL, wszMyComputer, NULL, &pidlMyComputer, NULL);
968  ok (hr == S_OK, "Desktop's ParseDisplayName failed to parse MyComputer's CLSID! hr = %08x\n", hr);
969  if (hr != S_OK) {
970  IShellFolder_Release(psfDesktop);
971  return;
972  }
973 
974  /* Windows sets the SFGAO_CANLINK flag, when MyComputer is queried via the Desktop
975  * folder object. It doesn't do this, if MyComputer is queried directly (see below).
976  */
977  dwFlags = 0xffffffff;
978  hr = IShellFolder_GetAttributesOf(psfDesktop, 1, (LPCITEMIDLIST*)&pidlMyComputer, &dwFlags);
979  ok (hr == S_OK, "Desktop->GetAttributesOf(MyComputer) failed! hr = %08x\n", hr);
980  todo_wine
981  ok (dwFlags == (myComputerFlags | SFGAO_CANLINK), "Wrong MyComputer attributes: %08x\n", dwFlags);
982 
983  hr = IShellFolder_BindToObject(psfDesktop, pidlMyComputer, NULL, &IID_IShellFolder, (LPVOID*)&psfMyComputer);
984  ok (hr == S_OK, "Desktop failed to bind to MyComputer object! hr = %08x\n", hr);
985  IShellFolder_Release(psfDesktop);
986  IMalloc_Free(ppM, pidlMyComputer);
987  if (hr != S_OK) return;
988 
989  hr = IShellFolder_GetAttributesOf(psfMyComputer, 1, &pidlEmpty, &dwFlags);
990  todo_wine
991  ok (hr == E_INVALIDARG, "MyComputer->GetAttributesOf(empty pidl) should fail! hr = %08x\n", hr);
992 
993  dwFlags = 0xffffffff;
994  hr = IShellFolder_GetAttributesOf(psfMyComputer, 0, NULL, &dwFlags);
995  ok (hr == S_OK, "MyComputer->GetAttributesOf(NULL) failed! hr = %08x\n", hr);
996  todo_wine
997  ok (dwFlags == myComputerFlags, "Wrong MyComputer attributes: %08x\n", dwFlags);
998 
999  IShellFolder_Release(psfMyComputer);
1000 
1001  GetCurrentDirectoryA(MAX_PATH, cCurrDirA);
1002  len = lstrlenA(cCurrDirA);
1003 
1004  if (len == 0) {
1005  win_skip("GetCurrentDirectoryA returned empty string. Skipping test_GetAttributesOf\n");
1006  return;
1007  }
1008  if (len > 3 && cCurrDirA[len-1] == '\\')
1009  cCurrDirA[len-1] = 0;
1010 
1011  /* create test directory */
1013 
1014  MultiByteToWideChar(CP_ACP, 0, cCurrDirA, -1, cCurrDirW, MAX_PATH);
1015 
1016  hr = SHGetDesktopFolder(&IDesktopFolder);
1017  ok(hr == S_OK, "SHGetDesktopfolder failed %08x\n", hr);
1018 
1019  hr = IShellFolder_ParseDisplayName(IDesktopFolder, NULL, NULL, cCurrDirW, NULL, &newPIDL, 0);
1020  ok(hr == S_OK, "ParseDisplayName failed %08x\n", hr);
1021 
1022  hr = IShellFolder_BindToObject(IDesktopFolder, newPIDL, NULL, (REFIID)&IID_IShellFolder, (LPVOID *)&testIShellFolder);
1023  ok(hr == S_OK, "BindToObject failed %08x\n", hr);
1024 
1025  IMalloc_Free(ppM, newPIDL);
1026 
1027  /* get relative PIDL */
1028  hr = IShellFolder_ParseDisplayName(testIShellFolder, NULL, NULL, cTestDirW, NULL, &newPIDL, 0);
1029  ok(hr == S_OK, "ParseDisplayName failed %08x\n", hr);
1030 
1031  /* test the shell attributes of the test directory using the relative PIDL */
1032  dwFlags = SFGAO_FOLDER;
1033  hr = IShellFolder_GetAttributesOf(testIShellFolder, 1, (LPCITEMIDLIST*)&newPIDL, &dwFlags);
1034  ok (hr == S_OK, "Desktop->GetAttributesOf() failed! hr = %08x\n", hr);
1035  ok ((dwFlags&SFGAO_FOLDER), "Wrong directory attribute for relative PIDL: %08x\n", dwFlags);
1036 
1037  /* free memory */
1038  IMalloc_Free(ppM, newPIDL);
1039 
1040  /* append testdirectory name to path */
1041  if (cCurrDirA[len-1] == '\\')
1042  cCurrDirA[len-1] = 0;
1043  lstrcatA(cCurrDirA, "\\testdir");
1044  MultiByteToWideChar(CP_ACP, 0, cCurrDirA, -1, cCurrDirW, MAX_PATH);
1045 
1046  hr = IShellFolder_ParseDisplayName(IDesktopFolder, NULL, NULL, cCurrDirW, NULL, &newPIDL, 0);
1047  ok(hr == S_OK, "ParseDisplayName failed %08x\n", hr);
1048 
1049  /* test the shell attributes of the test directory using the absolute PIDL */
1050  dwFlags = SFGAO_FOLDER;
1051  hr = IShellFolder_GetAttributesOf(IDesktopFolder, 1, (LPCITEMIDLIST*)&newPIDL, &dwFlags);
1052  ok (hr == S_OK, "Desktop->GetAttributesOf() failed! hr = %08x\n", hr);
1053  ok ((dwFlags&SFGAO_FOLDER), "Wrong directory attribute for absolute PIDL: %08x\n", dwFlags);
1054 
1055  /* free memory */
1056  IMalloc_Free(ppM, newPIDL);
1057 
1058  IShellFolder_Release(testIShellFolder);
1059 
1060  Cleanup();
1061 
1062  IShellFolder_Release(IDesktopFolder);
1063 }
static IBindCtx void **static IBindCtx void **static void **static IShellFolder LPCITEMIDLIST
Definition: shlfolder.c:53
static IBindCtx REFIID
Definition: shlfolder.c:50
HRESULT hr
Definition: shlfolder.c:183
#define CP_ACP
Definition: compat.h:99
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
static void CreateFilesFolders(void)
Definition: shlfolder.c:296
#define ok(value,...)
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
LPSTR WINAPI lstrcatA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:123
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
#define todo_wine
Definition: test.h:154
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
GLenum GLsizei len
Definition: glext.h:6722
#define S_OK
Definition: intsafe.h:59
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
DWORD WINAPI GetCurrentDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2145
static void Cleanup(void)
Definition: shlfolder.c:308
static IMalloc * ppM
Definition: shlfolder.c:47
#define MultiByteToWideChar
Definition: compat.h:100
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test_GetDefaultColumn()

static void test_GetDefaultColumn ( void  )
static

Definition at line 5157 of file shlfolder.c.

5158 {
5159  static const CLSID *folders[] =
5160  {
5161  &CLSID_MyComputer,
5162  &CLSID_MyDocuments,
5163  &CLSID_ControlPanel,
5164  &CLSID_NetworkPlaces,
5165  &CLSID_Printers,
5166  &CLSID_RecycleBin,
5167  &CLSID_ShellDesktop,
5168  };
5169  HRESULT hr;
5170  int i;
5171 
5172  CoInitialize(NULL);
5173 
5174  for (i = 0; i < ARRAY_SIZE(folders); i++)
5175  {
5177  ULONG sort, display;
5178 
5179  hr = CoCreateInstance(folders[i], NULL, CLSCTX_INPROC_SERVER, &IID_IShellFolder2, (void **)&folder);
5180  if (hr != S_OK)
5181  {
5182  win_skip("Failed to create folder %s, hr %#x.\n", wine_dbgstr_guid(folders[i]), hr);
5183  continue;
5184  }
5185 
5186  hr = IShellFolder2_GetDefaultColumn(folder, 0, NULL, NULL);
5187  ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr);
5188 
5189  sort = display = 123;
5190  hr = IShellFolder2_GetDefaultColumn(folder, 0, &sort, &display);
5191  ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr);
5192  ok(sort == 123 && display == 123, "Unexpected default column.\n");
5193 
5194  display = 123;
5195  hr = IShellFolder2_GetDefaultColumn(folder, 0, NULL, &display);
5196  ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr);
5197  ok(display == 123, "Unexpected default column.\n");
5198 
5199  sort = 123;
5200  hr = IShellFolder2_GetDefaultColumn(folder, 0, &sort, NULL);
5201  ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr);
5202  ok(sort == 123, "Unexpected default column.\n");
5203 
5204  IShellFolder2_Release(folder);
5205  }
5206 
5207  CoUninitialize();
5208 }
Definition: fci.c:115
HRESULT hr
Definition: shlfolder.c:183
_STLP_MOVE_TO_STD_NAMESPACE void sort(_RandomAccessIter __first, _RandomAccessIter __last)
Definition: _algo.c:993
const char * wine_dbgstr_guid(const GUID *guid)
int * display
Definition: x11stubs.c:12
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
struct CFFOLDER folder
Definition: fdi.c:110
LONG HRESULT
Definition: typedefs.h:77
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3234
#define S_OK
Definition: intsafe.h:59
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:1991
#define ARRAY_SIZE(a)
Definition: main.h:24
#define E_NOTIMPL
Definition: ddrawi.h:99
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1897
unsigned int ULONG
Definition: retypes.h:1
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test_GetDefaultSearchGUID()

static void test_GetDefaultSearchGUID ( void  )
static

Definition at line 5210 of file shlfolder.c.

5211 {
5212  static const CLSID *folders[] =
5213  {
5214  &CLSID_MyComputer,
5215  &CLSID_MyDocuments,
5216  &CLSID_ControlPanel,
5217  &CLSID_NetworkPlaces,
5218  &CLSID_Printers,
5219  &CLSID_RecycleBin,
5220  &CLSID_ShellDesktop,
5221  };
5222  HRESULT hr;
5223  int i;
5224 
5225  CoInitialize(NULL);
5226 
5227  for (i = 0; i < ARRAY_SIZE(folders); i++)
5228  {
5230  GUID guid;
5231 
5232  hr = CoCreateInstance(folders[i], NULL, CLSCTX_INPROC_SERVER, &IID_IShellFolder2, (void **)&folder);
5233  if (hr != S_OK)
5234  {
5235  win_skip("Failed to create folder %s, hr %#x.\n", wine_dbgstr_guid(folders[i]), hr);
5236  continue;
5237  }
5238 
5239  if (0)
5240  {
5241  /* crashes on XP */
5242  hr = IShellFolder2_GetDefaultSearchGUID(folder, NULL);
5243  ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr);
5244  }
5245 
5246  memcpy(&guid, &CLSID_MyComputer, sizeof(guid));
5247  hr = IShellFolder2_GetDefaultSearchGUID(folder, &guid);
5248  ok(hr == E_NOTIMPL || broken(hr == S_OK) /* Method was last supported on XP */, "Unexpected hr %#x.\n", hr);
5249  if (hr == E_NOTIMPL)
5250  ok(IsEqualGUID(&guid, &CLSID_MyComputer), "Unexpected guid %s.\n", wine_dbgstr_guid(&guid));
5251 
5252  IShellFolder2_Release(folder);
5253  }
5254 
5255  CoUninitialize();
5256 }
Definition: fci.c:115
HRESULT hr
Definition: shlfolder.c:183
const char * wine_dbgstr_guid(const GUID *guid)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
const GUID * guid
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
struct CFFOLDER folder
Definition: fdi.c:110
LONG HRESULT
Definition: typedefs.h:77
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define broken(x)
Definition: _sntprintf.h:21
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3234
#define S_OK
Definition: intsafe.h:59
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:1991
#define ARRAY_SIZE(a)
Definition: main.h:24
#define E_NOTIMPL
Definition: ddrawi.h:99
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4021
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1897
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test_GetDisplayName()

static void test_GetDisplayName ( void  )
static

Definition at line 639 of file shlfolder.c.

640 {
641  BOOL result;
642  HRESULT hr;
643  HANDLE hTestFile;
644  WCHAR wszTestFile[MAX_PATH], wszTestFile2[MAX_PATH];
645  char szTestFile[MAX_PATH], szTestDir[MAX_PATH];
646  DWORD attr;
647  STRRET strret;
648  LPSHELLFOLDER psfDesktop, psfPersonal;
649  IUnknown *psfFile;
650  SHITEMID emptyitem = { 0, { 0 } };
651  LPITEMIDLIST pidlTestFile, pidlEmpty = (LPITEMIDLIST)&emptyitem;
652  LPCITEMIDLIST pidlLast;
653  static const CHAR szFileName[] = "winetest.foo";
654  static const WCHAR wszFileName[] = { 'w','i','n','e','t','e','s','t','.','f','o','o',0 };
655  static const WCHAR wszDirName[] = { 'w','i','n','e','t','e','s','t',0 };
656 
657  /* It's ok to use this fixed path. Call will fail anyway. */
658  WCHAR wszAbsoluteFilename[] = { 'C',':','\\','w','i','n','e','t','e','s','t', 0 };
659  LPITEMIDLIST pidlNew;
660 
661  /* I'm trying to figure if there is a functional difference between calling
662  * SHGetPathFromIDListW and calling GetDisplayNameOf(SHGDN_FORPARSING) after
663  * binding to the shellfolder. One thing I thought of was that perhaps
664  * SHGetPathFromIDListW would be able to get the path to a file, which does
665  * not exist anymore, while the other method wouldn't. It turns out there's
666  * no functional difference in this respect.
667  */
668 
669  /* First creating a directory in MyDocuments and a file in this directory. */
671  ok(result, "SHGetSpecialFolderPathA failed! Last error: %u\n", GetLastError());
672  if (!result) return;
673 
674  /* Use ANSI file functions so this works on Windows 9x */
675  lstrcatA(szTestDir, "\\winetest");
676  CreateDirectoryA(szTestDir, NULL);
677  attr=GetFileAttributesA(szTestDir);
679  {
680  ok(0, "unable to create the '%s' directory\n", szTestDir);
681  return;
682  }
683 
684  lstrcpyA(szTestFile, szTestDir);
685  lstrcatA(szTestFile, "\\");
686  lstrcatA(szTestFile, szFileName);
687  hTestFile = CreateFileA(szTestFile, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
688  ok((hTestFile != INVALID_HANDLE_VALUE), "CreateFileA failed! Last error: %u\n", GetLastError());
689  if (hTestFile == INVALID_HANDLE_VALUE) return;
690  CloseHandle(hTestFile);
691 
692  /* Getting an itemidlist for the file. */
693  hr = SHGetDesktopFolder(&psfDesktop);
694  ok(hr == S_OK, "SHGetDesktopFolder failed! hr = %08x\n", hr);
695  if (hr != S_OK) return;
696 
697  MultiByteToWideChar(CP_ACP, 0, szTestFile, -1, wszTestFile, MAX_PATH);
698 
699  hr = IShellFolder_ParseDisplayName(psfDesktop, NULL, NULL, wszTestFile, NULL, &pidlTestFile, NULL);
700  ok(hr == S_OK, "Desktop->ParseDisplayName failed! hr = %08x\n", hr);
701  if (hr != S_OK) {
702  IShellFolder_Release(psfDesktop);
703  return;
704  }
705 
706  pidlLast = ILFindLastID(pidlTestFile);
707  ok(pidlLast->mkid.cb >= 76, "Expected pidl length of at least 76, got %d.\n", pidlLast->mkid.cb);
708  if (pidlLast->mkid.cb >= 28) {
709  ok(!lstrcmpA((CHAR*)&pidlLast->mkid.abID[12], szFileName),
710  "Filename should be stored as ansi-string at this position!\n");
711  }
712  /* WinXP and up store the filenames as both ANSI and UNICODE in the pidls */
713  if (pidlLast->mkid.cb >= 76) {
714  ok(!lstrcmpW((WCHAR*)&pidlLast->mkid.abID[46], wszFileName) ||
715  (pidlLast->mkid.cb >= 94 && !lstrcmpW((WCHAR*)&pidlLast->mkid.abID[64], wszFileName)) || /* Vista */
716  (pidlLast->mkid.cb >= 98 && !lstrcmpW((WCHAR*)&pidlLast->mkid.abID[68], wszFileName)) || /* Win7 */
717  (pidlLast->mkid.cb >= 102 && !lstrcmpW((WCHAR*)&pidlLast->mkid.abID[72], wszFileName)), /* Win8 */
718  "Filename should be stored as wchar-string at this position!\n");
719  }
720 
721  /* It seems as if we cannot bind to regular files on windows, but only directories.
722  */
723  hr = IShellFolder_BindToObject(psfDesktop, pidlTestFile, NULL, &IID_IUnknown, (VOID**)&psfFile);
725  hr == E_NOTIMPL, /* Vista */
726  "hr = %08x\n", hr);
727  if (hr == S_OK) {
728  IUnknown_Release(psfFile);
729  }
730 
731  /* Some tests for IShellFolder::SetNameOf */
732  hr = SHBindToParent(pidlTestFile, &IID_IShellFolder, (void **)&psfPersonal, &pidlLast);
733  ok(hr == S_OK, "SHBindToParent failed! hr = %08x\n", hr);
734 
735  /* The pidl returned through the last parameter of SetNameOf is a simple one. */
736  hr = IShellFolder_SetNameOf(psfPersonal, NULL, pidlLast, wszDirName, SHGDN_NORMAL, &pidlNew);
737  ok (hr == S_OK, "SetNameOf failed! hr = %08x\n", hr);
738 
739  ok (((ITEMIDLIST *)((BYTE *)pidlNew + pidlNew->mkid.cb))->mkid.cb == 0,
740  "pidl returned from SetNameOf should be simple!\n");
741 
742  /* Passing an absolute path to SetNameOf fails. The HRESULT code indicates that SetNameOf
743  * is implemented on top of SHFileOperation in WinXP. */
744  hr = IShellFolder_SetNameOf(psfPersonal, NULL, pidlNew, wszAbsoluteFilename, SHGDN_FORPARSING, NULL);
745  ok (hr == HRESULT_FROM_WIN32(ERROR_CANCELLED), "SetNameOf succeeded! hr = %08x\n", hr);
746 
747  /* Rename the file back to its original name. SetNameOf ignores the fact, that the
748  * SHGDN flags specify an absolute path. */
749  hr = IShellFolder_SetNameOf(psfPersonal, NULL, pidlNew, wszFileName, SHGDN_FORPARSING, NULL);
750  ok (hr == S_OK, "SetNameOf failed! hr = %08x\n", hr);
751 
752  ILFree(pidlNew);
753  IShellFolder_Release(psfPersonal);
754 
755  /* Deleting the file and the directory */
756  DeleteFileA(szTestFile);
757  RemoveDirectoryA(szTestDir);
758 
759  /* SHGetPathFromIDListW still works, although the file is not present anymore. */
760  result = SHGetPathFromIDListW(pidlTestFile, wszTestFile2);
761  ok (result, "SHGetPathFromIDListW failed! Last error: %u\n", GetLastError());
762  ok (!lstrcmpiW(wszTestFile, wszTestFile2), "SHGetPathFromIDListW returns incorrect path!\n");
763 
764  /* SHBindToParent fails, if called with a NULL PIDL. */
765  hr = SHBindToParent(NULL, &IID_IShellFolder, (void **)&psfPersonal, &pidlLast);
766  ok (hr == E_INVALIDARG || broken(hr == E_OUTOFMEMORY) /* XP */,
767  "SHBindToParent(NULL) should fail! hr = %08x\n", hr);
768 
769  /* But it succeeds with an empty PIDL. */
770  hr = SHBindToParent(pidlEmpty, &IID_IShellFolder, (void **)&psfPersonal, &pidlLast);
771  ok (hr == S_OK, "SHBindToParent(empty PIDL) should succeed! hr = %08x\n", hr);
772  ok (pidlLast == pidlEmpty, "The last element of an empty PIDL should be the PIDL itself!\n");
773  if (hr == S_OK)
774  IShellFolder_Release(psfPersonal);
775 
776  /* Binding to the folder and querying the display name of the file also works. */
777  hr = SHBindToParent(pidlTestFile, &IID_IShellFolder, (void **)&psfPersonal, &pidlLast);
778  ok (hr == S_OK, "SHBindToParent failed! hr = %08x\n", hr);
779  if (hr != S_OK) {
780  IShellFolder_Release(psfDesktop);
781  return;
782  }
783 
784  /* This test shows that Windows doesn't allocate a new pidlLast, but returns a pointer into
785  * pidlTestFile (In accordance with MSDN). */
786  ok (ILFindLastID(pidlTestFile) == pidlLast,
787  "SHBindToParent doesn't return the last id of the pidl param!\n");
788 
789  hr = IShellFolder_GetDisplayNameOf(psfPersonal, pidlLast, SHGDN_FORPARSING, &strret);
790  ok (hr == S_OK, "Personal->GetDisplayNameOf failed! hr = %08x\n", hr);
791  if (hr != S_OK) {
792  IShellFolder_Release(psfDesktop);
793  IShellFolder_Release(psfPersonal);
794  return;
795  }
796 
797  hr = StrRetToBufW(&strret, pidlLast, wszTestFile2, MAX_PATH);
798  ok (hr == S_OK, "StrRetToBufW failed! hr = %08x\n", hr);
799  ok (!lstrcmpiW(wszTestFile, wszTestFile2), "GetDisplayNameOf returns incorrect path!\n");
800 
801  ILFree(pidlTestFile);
802  IShellFolder_Release(psfDesktop);
803  IShellFolder_Release(psfPersonal);
804 }
static WCHAR wszFileName[MAX_PATH]
Definition: wordpad.c:70
#define CloseHandle
Definition: compat.h:398
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:925
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
HRESULT hr
Definition: shlfolder.c:183
#define CP_ACP
Definition: compat.h:99
HRESULT WINAPI StrRetToBufW(LPSTRRET src, const ITEMIDLIST *pidl, LPWSTR dest, UINT len)
Definition: string.c:1522
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
char CHAR
Definition: xmlstorage.h:175
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: pidl.c:1280
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
int WINAPI lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:18
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
BOOL WINAPI SHGetSpecialFolderPathA(HWND hwndOwner, LPSTR szPath, int nFolder, BOOL bCreate)
Definition: shellpath.c:2553
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
unsigned int BOOL
Definition: ntddk_ex.h:94
DWORD WINAPI GetFileAttributesA(LPCSTR lpFileName)
Definition: fileinfo.c:786
#define GENERIC_WRITE
Definition: nt_native.h:90
#define ok(value,...)
#define E_INVALIDARG
Definition: ddrawi.h:101
BOOL WINAPI CreateDirectoryA(IN LPCSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:37
smooth NULL
Definition: ftsmooth.c:416
LPITEMIDLIST WINAPI ILFindLastID(LPCITEMIDLIST pidl)
Definition: pidl.c:189
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
LPSTR WINAPI lstrcatA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:123
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
const GUID IID_IUnknown
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
Definition: cookie.c:170
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
__u8 attr
Definition: mkdosfs.c:359
unsigned char BYTE
Definition: mem.h:68
#define broken(x)
Definition: _sntprintf.h:21
#define S_OK
Definition: intsafe.h:59
#define CREATE_ALWAYS
Definition: disk.h:72
#define ERROR_CANCELLED
Definition: winerror.h:726
HRESULT WINAPI SHBindToParent(LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppv, LPCITEMIDLIST *ppidlLast)
Definition: pidl.c:1323
#define E_NOTIMPL
Definition: ddrawi.h:99
BOOL WINAPI RemoveDirectoryA(IN LPCSTR lpPathName)
Definition: dir.c:714
#define MultiByteToWideChar
Definition: compat.h:100
#define CSIDL_PERSONAL
Definition: shlobj.h:2008
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:399
GLuint64EXT * result
Definition: glext.h:11304
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41

Referenced by START_TEST().

◆ test_GetUIObject()

static void test_GetUIObject ( void  )
static

Definition at line 4476 of file shlfolder.c.

4477 {
4478  IShellFolder *psf_desktop;
4479  IContextMenu *pcm;
4480  LPITEMIDLIST pidl;
4481  HRESULT hr;
4482  WCHAR path[MAX_PATH];
4483  const WCHAR filename[] =
4484  {'\\','t','e','s','t','d','i','r','\\','t','e','s','t','1','.','t','x','t',0};
4485  LPCITEMIDLIST pidl_child;
4486  IShellFolder *psf;
4487 
4489  if (!path[0])
4490  {
4491  skip("GetCurrentDirectoryW returned an empty string.\n");
4492  return;
4493  }
4495  SHGetDesktopFolder(&psf_desktop);
4496 
4498 
4499  hr = IShellFolder_ParseDisplayName(psf_desktop, NULL, NULL, path, NULL, &pidl, 0);
4500  ok(hr == S_OK, "Got 0x%08x\n", hr);
4501 
4502  hr = SHBindToParent(pidl, &IID_IShellFolder, (void **)&psf, &pidl_child);
4503  ok(hr == S_OK, "Failed to bind to folder, hr %#x.\n", hr);
4504 
4505  /* Item menu */
4506  hr = IShellFolder_GetUIObjectOf(psf, NULL, 1, &pidl_child, &IID_IContextMenu, NULL, (void **)&pcm);
4507  ok(hr == S_OK, "GetUIObjectOf() failed, hr %#x.\n", hr);
4508  test_contextmenu(pcm, FALSE);
4509  IContextMenu_Release(pcm);
4510 
4511  /* Background menu */
4512  hr = IShellFolder_GetUIObjectOf(psf_desktop, NULL, 0, NULL, &IID_IContextMenu, NULL, (void **)&pcm);
4513  ok(hr == S_OK, "GetUIObjectOf() failed, hr %#x.\n", hr);
4514  test_contextmenu(pcm, TRUE);
4515  IContextMenu_Release(pcm);
4516 
4517  IShellFolder_Release(psf);
4518  ILFree(pidl);
4519 
4520  IShellFolder_Release(psf_desktop);
4521  Cleanup();
4522 }
#define TRUE
Definition: types.h:120
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:925
HRESULT hr
Definition: shlfolder.c:183
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
#define GetCurrentDirectoryW(x, y)
Definition: compat.h:413
const char * filename
Definition: ioapi.h:135
static void CreateFilesFolders(void)
Definition: shlfolder.c:296
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define MAX_PATH
Definition: compat.h:26
#define S_OK
Definition: intsafe.h:59
static void test_contextmenu(IContextMenu *menu, BOOL background)
Definition: shlfolder.c:4397
HRESULT WINAPI SHBindToParent(LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppv, LPCITEMIDLIST *ppidlLast)
Definition: pidl.c:1323
Definition: services.c:325
static void Cleanup(void)
Definition: shlfolder.c:308
#define skip(...)
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41

Referenced by START_TEST().

◆ test_ITEMIDLIST_format()

static void test_ITEMIDLIST_format ( void  )
static

Definition at line 1562 of file shlfolder.c.

1562  {
1563  WCHAR wszPersonal[MAX_PATH];
1564  LPSHELLFOLDER psfDesktop, psfPersonal;
1565  LPITEMIDLIST pidlPersonal, pidlFile;
1566  HANDLE hFile;
1567  HRESULT hr;
1568  BOOL bResult;
1569  WCHAR wszFile[3][17] = { { 'e','v','e','n','_',0 }, { 'o','d','d','_',0 },
1570  { 'l','o','n','g','e','r','_','t','h','a','n','.','8','_','3',0 } };
1571  int i;
1572 
1573  bResult = SHGetSpecialFolderPathW(NULL, wszPersonal, CSIDL_PERSONAL, FALSE);
1574  ok(bResult, "SHGetSpecialFolderPathW failed! Last error: %u\n", GetLastError());
1575  if (!bResult) return;
1576 
1577  SetLastError(0xdeadbeef);
1578  bResult = SetCurrentDirectoryW(wszPersonal);
1579  if (!bResult && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) {
1580  win_skip("Most W-calls are not implemented\n");
1581  return;
1582  }
1583  ok(bResult, "SetCurrentDirectory failed! Last error: %u\n", GetLastError());
1584  if (!bResult) return;
1585 
1586  hr = SHGetDesktopFolder(&psfDesktop);
1587  ok(hr == S_OK, "SHGetDesktopFolder failed! hr: %08x\n", hr);
1588  if (hr != S_OK) return;
1589 
1590  hr = IShellFolder_ParseDisplayName(psfDesktop, NULL, NULL, wszPersonal, NULL, &pidlPersonal, NULL);
1591  ok(hr == S_OK, "psfDesktop->ParseDisplayName failed! hr = %08x\n", hr);
1592  if (hr != S_OK) {
1593  IShellFolder_Release(psfDesktop);
1594  return;
1595  }
1596 
1597  hr = IShellFolder_BindToObject(psfDesktop, pidlPersonal, NULL, &IID_IShellFolder,
1598  (LPVOID*)&psfPersonal);
1599  IShellFolder_Release(psfDesktop);
1600  ILFree(pidlPersonal);
1601  ok(hr == S_OK, "psfDesktop->BindToObject failed! hr = %08x\n", hr);
1602  if (hr != S_OK) return;
1603 
1604  for (i=0; i<3; i++) {
1605  CHAR szFile[MAX_PATH];
1606  struct FileStructA *pFileStructA;
1607  WORD cbOffset;
1608 
1609  WideCharToMultiByte(CP_ACP, 0, wszFile[i], -1, szFile, MAX_PATH, NULL, NULL);
1610 
1612  ok(hFile != INVALID_HANDLE_VALUE, "CreateFile failed! (%u)\n", GetLastError());
1613  if (hFile == INVALID_HANDLE_VALUE) {
1614  IShellFolder_Release(psfPersonal);
1615  return;
1616  }
1617  CloseHandle(hFile);
1618 
1619  hr = IShellFolder_ParseDisplayName(psfPersonal, NULL, NULL, wszFile[i], NULL, &pidlFile, NULL);
1620  DeleteFileW(wszFile[i]);
1621  ok(hr == S_OK, "psfPersonal->ParseDisplayName failed! hr: %08x\n", hr);
1622  if (hr != S_OK) {
1623  IShellFolder_Release(psfPersonal);
1624  return;
1625  }
1626 
1627  pFileStructA = (struct FileStructA *)pidlFile->mkid.abID;
1628  ok(pFileStructA->type == 0x32, "PIDLTYPE should be 0x32!\n");
1629  ok(pFileStructA->dummy == 0x00, "Dummy Byte should be 0x00!\n");
1630  ok(pFileStructA->dwFileSize == 0, "Filesize should be zero!\n");
1631 
1632  if (i < 2) /* First two file names are already in valid 8.3 format */
1633  ok(!strcmp(szFile, (CHAR*)&pidlFile->mkid.abID[12]), "Wrong file name!\n");
1634  else
1635  /* WinXP stores a derived 8.3 dos name (LONGER~1.8_3) here. We probably
1636  * can't implement this correctly, since unix filesystems don't support
1637  * this nasty short/long filename stuff. So we'll probably stay with our
1638  * current habit of storing the long filename here, which seems to work
1639  * just fine. */
1640  todo_wine
1641  ok(pidlFile->mkid.abID[18] == '~', "Should be derived 8.3 name!\n");
1642 
1643  if (i == 0) /* First file name has an even number of chars. No need for alignment. */
1644  ok(pidlFile->mkid.abID[12 + strlen(szFile) + 1] != '\0',
1645  "Alignment byte, where there shouldn't be!\n");
1646 
1647  if (i == 1) /* Second file name has an uneven number of chars => alignment byte */
1648  ok(pidlFile->mkid.abID[12 + strlen(szFile) + 1] == '\0',
1649  "There should be an alignment byte, but isn't!\n");
1650 
1651  /* The offset of the FileStructW member is stored as a WORD at the end of the pidl. */
1652  cbOffset = *(WORD*)(((LPBYTE)pidlFile)+pidlFile->mkid.cb-sizeof(WORD));
1653  ok ((cbOffset >= sizeof(struct FileStructA) &&
1654  cbOffset <= pidlFile->mkid.cb - sizeof(struct FileStructW)),
1655  "Wrong offset value (%d) stored at the end of the PIDL\n", cbOffset);
1656 
1657  if (cbOffset >= sizeof(struct FileStructA) &&
1658  cbOffset <= pidlFile->mkid.cb - sizeof(struct FileStructW))
1659  {
1660  struct FileStructW *pFileStructW = (struct FileStructW *)(((LPBYTE)pidlFile)+cbOffset);
1661  WCHAR *name = pFileStructW->wszName;
1662 
1663  ok(pidlFile->mkid.cb == cbOffset + pFileStructW->cbLen,
1664  "FileStructW's offset and length should add up to the PIDL's length!\n");
1665 
1666  if (pidlFile->mkid.cb == cbOffset + pFileStructW->cbLen) {
1667  /* Since we just created the file, time of creation,
1668  * time of last access and time of last write access just be the same.
1669  * These tests seem to fail sometimes (on WinXP), if the test is run again shortly
1670  * after the first run. I do remember something with NTFS keeping the creation time
1671  * if a file is deleted and then created again within a couple of seconds or so.
1672  * Might be the reason. */
1673  ok (pFileStructA->uFileDate == pFileStructW->uDate &&
1674  pFileStructA->uFileTime == pFileStructW->uTime,
1675  "Last write time should match creation time!\n");
1676 
1677  /* On FAT filesystems the last access time is midnight
1678  local time, so the values of uDate2 and uTime2 will
1679  depend on the local timezone. If the times are exactly
1680  equal then the dates should be identical for both FAT
1681  and NTFS as no timezone is more than 1 day away from UTC.
1682  */
1683  if (pFileStructA->uFileTime == pFileStructW->uTime2)
1684  {
1685  ok (pFileStructA->uFileDate == pFileStructW->uDate2,
1686  "Last write date and time should match last access date and time!\n");
1687  }
1688  else
1689  {
1690  /* Filesystem may be FAT. Check date within 1 day
1691  and seconds are zero. */
1692  trace ("Filesystem may be FAT. Performing less strict atime test.\n");
1693  ok ((pFileStructW->uTime2 & 0x1F) == 0,
1694  "Last access time on FAT filesystems should have zero seconds.\n");
1695  /* TODO: Perform check for date being within one day.*/
1696  }
1697 
1698  ok (!lstrcmpW(wszFile[i], name) ||
1699  !lstrcmpW(wszFile[i], name + 9) || /* Vista */
1700  !lstrcmpW(wszFile[i], name + 11) || /* Win7 */
1701  !lstrcmpW(wszFile[i], name + 13), /* Win8 */
1702  "The filename should be stored in unicode at this position!\n");
1703  }
1704  }
1705 
1706  ILFree(pidlFile);
1707  }
1708 
1709  IShellFolder_Release(psfPersonal);
1710 }
WORD uFileTime
Definition: shlfolder.c:1542
DWORD dwFileSize
Definition: shlfolder.c:1540
#define trace(...)
Definition: kmt_test.h:217
#define CloseHandle
Definition: compat.h:398
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:925
#define WideCharToMultiByte
Definition: compat.h:101
HRESULT hr
Definition: shlfolder.c:183
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define CP_ACP
Definition: compat.h:99
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
WCHAR wszName[1]
Definition: shlfolder.c:1555
char CHAR
Definition: xmlstorage.h:175
WORD uFileDate
Definition: shlfolder.c:1541
WORD cbOffset
Definition: shlfolder.c:1557
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned char * LPBYTE
Definition: typedefs.h:52
static const WCHAR wszFile[]
Definition: urlmon_main.c:386
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GENERIC_WRITE
Definition: nt_native.h:90
#define ok(value,...)
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
smooth NULL
Definition: ftsmooth.c:416
#define FILE_FLAG_WRITE_THROUGH
Definition: disk.h:47
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define MAX_PATH
Definition: compat.h:26
unsigned short WORD
Definition: ntddk_ex.h:93
#define SetLastError(x)
Definition: compat.h:409
#define todo_wine
Definition: test.h:154
_In_ HANDLE hFile
Definition: mswsock.h:90
#define S_OK
Definition: intsafe.h:59
BOOL WINAPI SHGetSpecialFolderPathW(HWND hwndOwner, LPWSTR szPath, int nFolder, BOOL bCreate)
Definition: shellpath.c:2566
BOOL WINAPI SetCurrentDirectoryW(IN LPCWSTR lpPathName)
Definition: path.c:2248
#define CreateFileW
Definition: compat.h:400
#define CSIDL_PERSONAL
Definition: shlobj.h:2008
Definition: name.c:36
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92
#define CREATE_NEW
Definition: disk.h:69
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test_LocalizedNames()

static void test_LocalizedNames ( void  )
static

Definition at line 1896 of file shlfolder.c.

1897 {
1898  static char cCurrDirA[MAX_PATH];
1899  WCHAR cCurrDirW[MAX_PATH], tempbufW[25];
1900  IShellFolder *IDesktopFolder, *testIShellFolder;
1901  ITEMIDLIST *newPIDL;
1902  int len;
1903  HRESULT hr;
1904  static char resourcefile[MAX_PATH];
1905  DWORD res;
1906  HANDLE file;
1907  STRRET strret;
1908  BOOL ret;
1909 
1910  static const char desktopini_contents1[] =
1911  "[.ShellClassInfo]\r\n"
1912  "LocalizedResourceName=@";
1913  static const char desktopini_contents2[] =
1914  ",-1\r\n";
1915  static WCHAR foldernameW[] = {'t','e','s','t','f','o','l','d','e','r',0};
1916  static const WCHAR folderdisplayW[] = {'F','o','l','d','e','r',' ','N','a','m','e',' ','R','e','s','o','u','r','c','e',0};
1917 
1918  /* create folder with desktop.ini and localized name in GetModuleFileNameA(NULL) */
1919  CreateDirectoryA(".\\testfolder", NULL);
1920 
1921  SetFileAttributesA(".\\testfolder", GetFileAttributesA(".\\testfolder")|FILE_ATTRIBUTE_SYSTEM);
1922 
1923  GetModuleFileNameA(NULL, resourcefile, MAX_PATH);
1924 
1925  file = CreateFileA(".\\testfolder\\desktop.ini", GENERIC_WRITE, 0, NULL,
1927  ok(file != INVALID_HANDLE_VALUE, "CreateFileA failed %i\n", GetLastError());
1928  ret = WriteFile(file, desktopini_contents1, strlen(desktopini_contents1), &res, NULL) &&
1929  WriteFile(file, resourcefile, strlen(resourcefile), &res, NULL) &&
1930  WriteFile(file, desktopini_contents2, strlen(desktopini_contents2), &res, NULL);
1931  ok(ret, "WriteFile failed %i\n", GetLastError());
1932  CloseHandle(file);
1933 
1934  /* get IShellFolder for parent */
1935  GetCurrentDirectoryA(MAX_PATH, cCurrDirA);
1936  len = lstrlenA(cCurrDirA);
1937 
1938  if (len == 0) {
1939  win_skip("GetCurrentDirectoryA returned empty string. Skipping test_LocalizedNames\n");
1940  goto cleanup;
1941  }
1942  if(cCurrDirA[len-1] == '\\')
1943  cCurrDirA[len-1] = 0;
1944 
1945  MultiByteToWideChar(CP_ACP, 0, cCurrDirA, -1, cCurrDirW, MAX_PATH);
1946 
1947  hr = SHGetDesktopFolder(&IDesktopFolder);
1948  ok(hr == S_OK, "SHGetDesktopfolder failed %08x\n", hr);
1949 
1950  hr = IShellFolder_ParseDisplayName(IDesktopFolder, NULL, NULL, cCurrDirW, NULL, &newPIDL, 0);
1951  ok(hr == S_OK, "ParseDisplayName failed %08x\n", hr);
1952 
1953  hr = IShellFolder_BindToObject(IDesktopFolder, newPIDL, NULL, (REFIID)&IID_IShellFolder, (LPVOID *)&testIShellFolder);
1954  ok(hr == S_OK, "BindToObject failed %08x\n", hr);
1955 
1956  IMalloc_Free(ppM, newPIDL);
1957 
1958  /* windows reads the display name from the resource */
1959  hr = IShellFolder_ParseDisplayName(testIShellFolder, NULL, NULL, foldernameW, NULL, &newPIDL, 0);
1960  ok(hr == S_OK, "ParseDisplayName failed %08x\n", hr);
1961 
1962  hr = IShellFolder_GetDisplayNameOf(testIShellFolder, newPIDL, SHGDN_INFOLDER, &strret);
1963  ok(hr == S_OK, "GetDisplayNameOf failed %08x\n", hr);
1964 
1965  hr = StrRetToBufW(&strret, newPIDL, tempbufW, ARRAY_SIZE(tempbufW));
1966  ok (hr == S_OK, "StrRetToBufW failed! hr = %08x\n", hr);
1967  todo_wine
1968  ok (!lstrcmpiW(tempbufW, folderdisplayW), "GetDisplayNameOf returned %s\n", wine_dbgstr_w(tempbufW));
1969 
1970  /* editing name is also read from the resource */
1971  hr = IShellFolder_GetDisplayNameOf(testIShellFolder, newPIDL, SHGDN_INFOLDER|SHGDN_FOREDITING, &strret);
1972  ok(hr == S_OK, "GetDisplayNameOf failed %08x\n", hr);
1973 
1974  hr = StrRetToBufW(&strret, newPIDL, tempbufW, ARRAY_SIZE(tempbufW));
1975  ok (hr == S_OK, "StrRetToBufW failed! hr = %08x\n", hr);
1976  todo_wine
1977  ok (!lstrcmpiW(tempbufW, folderdisplayW), "GetDisplayNameOf returned %s\n", wine_dbgstr_w(tempbufW));
1978 
1979  /* parsing name is unchanged */
1980  hr = IShellFolder_GetDisplayNameOf(testIShellFolder, newPIDL, SHGDN_INFOLDER|SHGDN_FORPARSING, &strret);
1981  ok(hr == S_OK, "GetDisplayNameOf failed %08x\n", hr);
1982 
1983  hr = StrRetToBufW(&strret, newPIDL, tempbufW, ARRAY_SIZE(tempbufW));
1984  ok (hr == S_OK, "StrRetToBufW failed! hr = %08x\n", hr);
1985  ok (!lstrcmpiW(tempbufW, foldernameW), "GetDisplayNameOf returned %s\n", wine_dbgstr_w(tempbufW));
1986 
1987  IShellFolder_Release(IDesktopFolder);
1988  IShellFolder_Release(testIShellFolder);
1989 
1990  IMalloc_Free(ppM, newPIDL);
1991 
1992 cleanup:
1993  DeleteFileA(".\\testfolder\\desktop.ini");
1994  SetFileAttributesA(".\\testfolder", GetFileAttributesA(".\\testfolder")&~FILE_ATTRIBUTE_SYSTEM);
1995  RemoveDirectoryA(".\\testfolder");
1996 }
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define CloseHandle
Definition: compat.h:398
static IBindCtx REFIID
Definition: shlfolder.c:50
HRESULT hr
Definition: shlfolder.c:183
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define FILE_ATTRIBUTE_SYSTEM
Definition: nt_native.h:704
#define CP_ACP
Definition: compat.h:99
HRESULT WINAPI StrRetToBufW(LPSTRRET src, const ITEMIDLIST *pidl, LPWSTR dest, UINT len)
Definition: string.c:1522
#define wine_dbgstr_w
Definition: kernel32.h:34
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
DWORD WINAPI GetModuleFileNameA(HINSTANCE hModule, LPSTR lpFilename, DWORD nSize)
Definition: loader.c:546
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
unsigned int BOOL
Definition: ntddk_ex.h:94
DWORD WINAPI GetFileAttributesA(LPCSTR lpFileName)
Definition: fileinfo.c:786
#define GENERIC_WRITE
Definition: nt_native.h:90
#define ok(value,...)
BOOL WINAPI CreateDirectoryA(IN LPCSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:37
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
BOOL WINAPI SetFileAttributesA(LPCSTR lpFileName, DWORD dwFileAttributes)
Definition: fileinfo.c:926
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define MAX_PATH
Definition: compat.h:26
const char file[]
Definition: icontest.c:11
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
#define todo_wine
Definition: test.h:154
GLenum GLsizei len
Definition: glext.h:6722
#define S_OK
Definition: intsafe.h:59
#define CREATE_ALWAYS
Definition: disk.h:72
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define ARRAY_SIZE(a)
Definition: main.h:24
DWORD WINAPI GetCurrentDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2145
BOOL WINAPI RemoveDirectoryA(IN LPCSTR lpPathName)
Definition: dir.c:714
static IMalloc * ppM
Definition: shlfolder.c:47
#define MultiByteToWideChar
Definition: compat.h:100
GLuint res
Definition: glext.h:9613
char * cleanup(char *str)
Definition: wpickclick.c:99
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:399
#define win_skip
Definition: test.h:141
Definition: fci.c:126

Referenced by START_TEST().

◆ test_ParseDisplayName()

static void test_ParseDisplayName ( void  )
static

Definition at line 207 of file shlfolder.c.

208 {
209  static WCHAR testdirW[] = {'p','a','r','s','e','t','e','s','t',0};
210  static WCHAR backslashW[] = {'\\',0};
211  WCHAR buffer[MAX_PATH], buffer2[MAX_PATH];
212  IShellFolder *desktop;
213  ITEMIDLIST *pidl;
214  HRESULT hr;
215  BOOL bRes;
216  int i;
217 
218  hr = SHGetDesktopFolder(&desktop);
219  ok(hr == S_OK, "Expected SHGetDesktopFolder to return S_OK, got 0x%08x\n", hr);
220 
221  hr = IShellFolder_ParseDisplayName(desktop, NULL, NULL, NULL, NULL, &pidl, NULL);
222  ok(hr == E_INVALIDARG, "got %#x\n", hr);
223 
224  for (i = 0; i < ARRAY_SIZE(parse_tests); i++)
225  {
226  hr = IShellFolder_ParseDisplayName(desktop, NULL, NULL, parse_tests[i].path, NULL, &pidl, NULL);
228  ok(hr == parse_tests[i].hr, "%s: expected %#x, got %#x\n",
230  if (SUCCEEDED(hr))
231  CoTaskMemFree(pidl);
232  }
233 
234  /* I thought that perhaps the DesktopFolder's ParseDisplayName would recognize the
235  * path corresponding to CSIDL_PERSONAL and return a CLSID_MyDocuments PIDL. Turns
236  * out it doesn't. The magic seems to happen in the file dialogs, then. */
237 
239  ok(bRes, "SHGetSpecialFolderPath(CSIDL_PERSONAL) failed! %u\n", GetLastError());
240 
241  hr = IShellFolder_ParseDisplayName(desktop, NULL, NULL, buffer, NULL, &pidl, 0);
242  ok(hr == S_OK, "DesktopFolder->ParseDisplayName failed. hr = %08x.\n", hr);
243 
244  ok(ILFindLastID(pidl)->mkid.abID[0] == 0x31,
245  "Last pidl should be of type PT_FOLDER, but is: %02x\n",
246  ILFindLastID(pidl)->mkid.abID[0]);
247  CoTaskMemFree(pidl);
248 
249  /* Relative paths are interpreted relative to the desktop. */
253  CreateDirectoryW(testdirW, NULL);
254 
255  hr = IShellFolder_ParseDisplayName(desktop, NULL, NULL, testdirW, NULL, &pidl, NULL);
256  ok(hr == 0x80070002, "got %#x\n", hr);
257 
258  RemoveDirectoryW(testdirW);
259 
261  ok(hr == S_FALSE, "got %#x\n", hr);
263  CreateDirectoryW(testdirW, NULL);
264 
265  hr = IShellFolder_ParseDisplayName(desktop, NULL, NULL, testdirW, NULL, &pidl, NULL);
266  ok(hr == S_OK, "got %#x\n", hr);
267 
268  ok(SHGetPathFromIDListW(pidl, buffer2), "SHGetPathFromIDList failed\n");
270  lstrcatW(buffer, testdirW);
271  ok(!lstrcmpW(buffer, buffer2), "expected %s, got %s\n", wine_dbgstr_w(buffer), wine_dbgstr_w(buffer2));
272 
273  RemoveDirectoryW(testdirW);
274  CoTaskMemFree(pidl);
275 
276  IShellFolder_Release(desktop);
277 }
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:90
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:422
HRESULT hr
Definition: shlfolder.c:183
#define CSIDL_DESKTOP
Definition: shlobj.h:2003
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: pidl.c:1280
#define wine_dbgstr_w
Definition: kernel32.h:34
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
GLuint buffer
Definition: glext.h:5915
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
DWORD WINAPI GetTempPathW(IN DWORD count, OUT LPWSTR path)
Definition: path.c:2079
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ok(value,...)
#define S_FALSE
Definition: winerror.h:2357
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
int todo
Definition: shlfolder.c:184
LPITEMIDLIST WINAPI ILFindLastID(LPCITEMIDLIST pidl)
Definition: pidl.c:189
BOOL WINAPI RemoveDirectoryW(IN LPCWSTR lpPathName)
Definition: dir.c:732
#define todo_wine_if(is_todo)
Definition: test.h:155
static const WCHAR backslashW[]
DWORD WINAPI GetLongPathNameW(IN LPCWSTR lpszShortPath, OUT LPWSTR lpszLongPath, IN DWORD cchBuffer)
Definition: path.c:1455
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define MAX_PATH
Definition: compat.h:26
#define S_OK
Definition: intsafe.h:59
BOOL WINAPI SHGetSpecialFolderPathW(HWND hwndOwner, LPWSTR szPath, int nFolder, BOOL bCreate)
Definition: shellpath.c:2566
#define ARRAY_SIZE(a)
Definition: main.h:24
BOOL WINAPI SetCurrentDirectoryW(IN LPCWSTR lpPathName)
Definition: path.c:2248
Definition: services.c:325
#define CSIDL_PERSONAL
Definition: shlobj.h:2008
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
static struct @1626 parse_tests[]
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by START_TEST().

◆ test_ParseDisplayNamePBC()

static void test_ParseDisplayNamePBC ( void  )
static

Definition at line 4674 of file shlfolder.c.

4675 {
4676  WCHAR wFileSystemBindData[] =
4677  {'F','i','l','e',' ','S','y','s','t','e','m',' ','B','i','n','d',' ','D','a','t','a',0};
4678  WCHAR adirW[] = {'C',':','\\','f','s','b','d','d','i','r',0};
4679  WCHAR afileW[] = {'C',':','\\','f','s','b','d','d','i','r','\\','f','i','l','e','.','t','x','t',0};
4680  WCHAR afile2W[] = {'C',':','\\','f','s','b','d','d','i','r','\\','s','\\','f','i','l','e','.','t','x','t',0};
4682 
4683  IShellFolder *psf;
4684  IBindCtx *pbc;
4685  HRESULT hres;
4686  ITEMIDLIST *pidl;
4687 
4688  /* Check if we support WCHAR functions */
4689  SetLastError(0xdeadbeef);
4690  lstrcmpiW(adirW, adirW);
4692  win_skip("Most W-calls are not implemented\n");
4693  return;
4694  }
4695 
4696  hres = SHGetDesktopFolder(&psf);
4697  ok(hres == S_OK, "SHGetDesktopFolder failed: 0x%08x\n", hres);
4698  if(FAILED(hres)){
4699  win_skip("Failed to get IShellFolder, can't run tests\n");
4700  return;
4701  }
4702 
4703  /* fails on unknown dir with no IBindCtx */
4704  hres = IShellFolder_ParseDisplayName(psf, NULL, NULL, adirW, NULL, &pidl, NULL);
4705  ok(hres == exp_err, "ParseDisplayName failed with wrong error: 0x%08x\n", hres);
4706  hres = IShellFolder_ParseDisplayName(psf, NULL, NULL, afileW, NULL, &pidl, NULL);
4707  ok(hres == exp_err, "ParseDisplayName failed with wrong error: 0x%08x\n", hres);
4708  hres = IShellFolder_ParseDisplayName(psf, NULL, NULL, afile2W, NULL, &pidl, NULL);
4709  ok(hres == exp_err, "ParseDisplayName failed with wrong error: 0x%08x\n", hres);
4710 
4711  /* fails on unknown dir with IBindCtx with no IFileSystemBindData */
4712  hres = CreateBindCtx(0, &pbc);
4713  ok(hres == S_OK, "CreateBindCtx failed: 0x%08x\n", hres);
4714 
4715  hres = IShellFolder_ParseDisplayName(psf, NULL, pbc, adirW, NULL, &pidl, NULL);
4716  ok(hres == exp_err, "ParseDisplayName failed with wrong error: 0x%08x\n",