From f8a4f6b59b4ffa294aeda584c4f94aab29acd340 Mon Sep 17 00:00:00 2001 From: Mike McCormack Date: Wed, 23 Feb 2005 12:45:12 +0000 Subject: [PATCH] - handle IFileSystemBindData in ISF_Desktop_fnParseDisplayName - more Unicode conversion --- dlls/shell32/enumidlist.c | 28 ++++++++++++++++------------ dlls/shell32/enumidlist.h | 2 +- dlls/shell32/pidl.h | 1 + dlls/shell32/shfldr.h | 1 + dlls/shell32/shfldr_desktop.c | 15 ++++++++++----- dlls/shell32/shfldr_fs.c | 6 +++++- 6 files changed, 34 insertions(+), 19 deletions(-) diff --git a/dlls/shell32/enumidlist.c b/dlls/shell32/enumidlist.c index 1d78e29cbe3..072e3288f3d 100644 --- a/dlls/shell32/enumidlist.c +++ b/dlls/shell32/enumidlist.c @@ -25,6 +25,7 @@ #define COBJMACROS #include "wine/debug.h" +#include "wine/unicode.h" #include "windef.h" #include "winbase.h" #include "winreg.h" @@ -103,24 +104,27 @@ BOOL AddToEnumList( */ BOOL CreateFolderEnumList( IEnumIDList *list, - LPCSTR lpszPath, + LPCWSTR lpszPath, DWORD dwFlags) { LPITEMIDLIST pidl=NULL; - WIN32_FIND_DATAA stffile; + WIN32_FIND_DATAW stffile; HANDLE hFile; - CHAR szPath[MAX_PATH]; + WCHAR szPath[MAX_PATH]; BOOL succeeded = TRUE; + const static WCHAR stars[] = { '*','.','*',0 }; + const static WCHAR dot[] = { '.',0 }; + const static WCHAR dotdot[] = { '.','.',0 }; - TRACE("(%p)->(path=%s flags=0x%08lx) \n",list,debugstr_a(lpszPath),dwFlags); + TRACE("(%p)->(path=%s flags=0x%08lx) \n",list,debugstr_w(lpszPath),dwFlags); if(!lpszPath || !lpszPath[0]) return FALSE; - strcpy(szPath, lpszPath); - PathAddBackslashA(szPath); - strcat(szPath,"*.*"); + strcpyW(szPath, lpszPath); + PathAddBackslashW(szPath); + strcatW(szPath,stars); - hFile = FindFirstFileA(szPath,&stffile); + hFile = FindFirstFileW(szPath,&stffile); if ( hFile != INVALID_HANDLE_VALUE ) { BOOL findFinished = FALSE; @@ -132,21 +136,21 @@ BOOL CreateFolderEnumList( { if ( (stffile.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && dwFlags & SHCONTF_FOLDERS && - strcmp (stffile.cFileName, ".") && strcmp (stffile.cFileName, "..")) + strcmpW(stffile.cFileName, dot) && strcmpW(stffile.cFileName, dotdot)) { - pidl = _ILCreateFromFindDataA(&stffile); + pidl = _ILCreateFromFindDataW(&stffile); succeeded = succeeded && AddToEnumList(list, pidl); } else if (!(stffile.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && dwFlags & SHCONTF_NONFOLDERS) { - pidl = _ILCreateFromFindDataA(&stffile); + pidl = _ILCreateFromFindDataW(&stffile); succeeded = succeeded && AddToEnumList(list, pidl); } } if (succeeded) { - if (!FindNextFileA(hFile, &stffile)) + if (!FindNextFileW(hFile, &stffile)) { if (GetLastError() == ERROR_NO_MORE_FILES) findFinished = TRUE; diff --git a/dlls/shell32/enumidlist.h b/dlls/shell32/enumidlist.h index 53b8b5ff111..26972aa191a 100644 --- a/dlls/shell32/enumidlist.h +++ b/dlls/shell32/enumidlist.h @@ -25,6 +25,6 @@ BOOL AddToEnumList(IEnumIDList *list, LPITEMIDLIST pidl); /* Enumerates the folders and/or files (depending on dwFlags) in lpszPath and * adds them to the already-created list. */ -BOOL CreateFolderEnumList(IEnumIDList *list, LPCSTR lpszPath, DWORD dwFlags); +BOOL CreateFolderEnumList(IEnumIDList *list, LPCWSTR lpszPath, DWORD dwFlags); #endif /* ndef __ENUMIDLIST_H__ */ diff --git a/dlls/shell32/pidl.h b/dlls/shell32/pidl.h index 9ae3a633a38..1bf1828beba 100644 --- a/dlls/shell32/pidl.h +++ b/dlls/shell32/pidl.h @@ -208,6 +208,7 @@ LPITEMIDLIST _ILCreateGuid(PIDLTYPE type, REFIID guid); /* Like _ILCreateGuid, but using the string szGUID. */ LPITEMIDLIST _ILCreateGuidFromStrA(LPCSTR szGUID); +LPITEMIDLIST _ILCreateGuidFromStrW(LPCWSTR szGUID); /* Commonly used PIDLs representing file system objects. */ LPITEMIDLIST _ILCreateDesktop (void); diff --git a/dlls/shell32/shfldr.h b/dlls/shell32/shfldr.h index 5666f0d7cc3..1a669bbb2c2 100644 --- a/dlls/shell32/shfldr.h +++ b/dlls/shell32/shfldr.h @@ -46,6 +46,7 @@ HRESULT SHELL32_BindToChild (LPCITEMIDLIST pidlRoot, LPCSTR pathRoot, LPCITEMIDLIST pidlComplete, REFIID riid, LPVOID * ppvOut); HRESULT SHELL32_CompareIDs (IShellFolder * iface, LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2); +LPITEMIDLIST SHELL32_CreatePidlFromBindCtx(IBindCtx *pbc, LPCWSTR path); static inline int SHELL32_GUIDToStringA (REFGUID guid, LPSTR str) { diff --git a/dlls/shell32/shfldr_desktop.c b/dlls/shell32/shfldr_desktop.c index fb9001dfcca..72759dcecd4 100644 --- a/dlls/shell32/shfldr_desktop.c +++ b/dlls/shell32/shfldr_desktop.c @@ -240,6 +240,11 @@ static HRESULT WINAPI ISF_Desktop_fnParseDisplayName (IShellFolder2 * iface, pidlTemp = _ILCreateNetwork(); szNext = lpszDisplayName; } + else if( (pidlTemp = SHELL32_CreatePidlFromBindCtx(pbc, lpszDisplayName)) ) + { + *ppidl = pidlTemp; + return S_OK; + } else { /* it's a filesystem path on the desktop. Let a FSFolder parse it */ @@ -288,7 +293,7 @@ static HRESULT WINAPI ISF_Desktop_fnParseDisplayName (IShellFolder2 * iface, static BOOL CreateDesktopEnumList(IEnumIDList *list, DWORD dwFlags) { BOOL ret = TRUE; - char szPath[MAX_PATH]; + WCHAR szPath[MAX_PATH]; TRACE("(%p)->(flags=0x%08lx) \n",list,dwFlags); @@ -307,7 +312,7 @@ static BOOL CreateDesktopEnumList(IEnumIDList *list, DWORD dwFlags) 0, KEY_READ, &hkey); if (ret && ERROR_SUCCESS == r) { - char iid[50]; + WCHAR iid[50]; int i=0; BOOL moreKeys = TRUE; @@ -316,10 +321,10 @@ static BOOL CreateDesktopEnumList(IEnumIDList *list, DWORD dwFlags) DWORD size; size = sizeof (iid); - r = RegEnumKeyExA(hkey, i, iid, &size, 0, NULL, NULL, NULL); + r = RegEnumKeyExW(hkey, i, iid, &size, 0, NULL, NULL, NULL); if (ERROR_SUCCESS == r) { - ret = AddToEnumList(list, _ILCreateGuidFromStrA(iid)); + ret = AddToEnumList(list, _ILCreateGuidFromStrW(iid)); i++; } else if (ERROR_NO_MORE_ITEMS == r) @@ -332,7 +337,7 @@ static BOOL CreateDesktopEnumList(IEnumIDList *list, DWORD dwFlags) } /* enumerate the elements in %windir%\desktop */ - SHGetSpecialFolderPathA(0, szPath, CSIDL_DESKTOPDIRECTORY, FALSE); + SHGetSpecialFolderPathW(0, szPath, CSIDL_DESKTOPDIRECTORY, FALSE); ret = ret && CreateFolderEnumList(list, szPath, dwFlags); return ret; diff --git a/dlls/shell32/shfldr_fs.c b/dlls/shell32/shfldr_fs.c index 2244ba622ae..0568b57e149 100644 --- a/dlls/shell32/shfldr_fs.c +++ b/dlls/shell32/shfldr_fs.c @@ -444,7 +444,11 @@ IShellFolder_fnEnumObjects (IShellFolder2 * iface, HWND hwndOwner, DWORD dwFlags *ppEnumIDList = IEnumIDList_Constructor(); if (*ppEnumIDList) - CreateFolderEnumList(*ppEnumIDList, This->sPathTarget, dwFlags); + { + WCHAR path[MAX_PATH]; + MultiByteToWideChar(CP_ACP, 0, This->sPathTarget, -1, path, MAX_PATH); + CreateFolderEnumList(*ppEnumIDList, path, dwFlags); + } TRACE ("-- (%p)->(new ID List: %p)\n", This, *ppEnumIDList);