diff --git a/dlls/shell32/shfldr.h b/dlls/shell32/shfldr.h index 1a669bbb2c2..bc35caf02e6 100644 --- a/dlls/shell32/shfldr.h +++ b/dlls/shell32/shfldr.h @@ -56,4 +56,17 @@ static inline int SHELL32_GUIDToStringA (REFGUID guid, LPSTR str) guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7]); } +static inline int SHELL32_GUIDToStringW (REFGUID guid, LPWSTR str) +{ + static const WCHAR fmtW[] = + { '{','%','0','8','l','x','-','%','0','4','x','-','%','0','4','x','-', + '%','0','2','x','%','0','2','x','-', + '%','0','2','x','%','0','2','x','%','0','2','x','%','0','2','x', + '%','0','2','x','%','0','2','x','}',0 }; + return sprintfW(str, fmtW, + guid->Data1, guid->Data2, guid->Data3, + guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3], + guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7]); +} + void SHELL_FS_ProcessDisplayFilename(LPSTR szPath, DWORD dwFlags); diff --git a/dlls/shell32/shfldr_desktop.c b/dlls/shell32/shfldr_desktop.c index 72759dcecd4..7c0d6cf64f4 100644 --- a/dlls/shell32/shfldr_desktop.c +++ b/dlls/shell32/shfldr_desktop.c @@ -206,8 +206,6 @@ static HRESULT WINAPI ISF_Desktop_fnParseDisplayName (IShellFolder2 * iface, LPCWSTR szNext = NULL; LPITEMIDLIST pidlTemp = NULL; HRESULT hr = S_OK; - char szPath[MAX_PATH]; - DWORD len; CLSID clsid; TRACE ("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n", @@ -251,13 +249,24 @@ static HRESULT WINAPI ISF_Desktop_fnParseDisplayName (IShellFolder2 * iface, if (*lpszDisplayName) { + WCHAR szPath[MAX_PATH]; + LPWSTR pathPtr; + /* build a complete path to create a simple pidl */ - lstrcpyA(szPath, This->sPathTarget); - PathAddBackslashA(szPath); - len = lstrlenA(szPath); - WideCharToMultiByte(CP_ACP, 0, lpszDisplayName, -1, - szPath + len, MAX_PATH - len, NULL, NULL); - hr = _ILCreateFromPathA(szPath, &pidlTemp); + MultiByteToWideChar(CP_ACP, 0, This->sPathTarget, -1, szPath, + sizeof(szPath) / sizeof(szPath[0])); + pathPtr = PathAddBackslashW(szPath); + if (pathPtr) + { + lstrcpynW(pathPtr, lpszDisplayName, + sizeof(szPath)/sizeof(szPath[0]) - (pathPtr - szPath)); + hr = _ILCreateFromPathW(szPath, &pidlTemp); + } + else + { + /* should never reach here, but for completeness */ + hr = HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); + } } else pidlTemp = _ILCreateMyComputer(); @@ -290,6 +299,12 @@ static HRESULT WINAPI ISF_Desktop_fnParseDisplayName (IShellFolder2 * iface, /************************************************************************** * CreateDesktopEnumList() */ +static const WCHAR Desktop_NameSpaceW[] = { 'S','O','F','T','W','A','R','E', + '\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\', + 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l', + 'o','r','e','r','\\','D','e','s','k','t','o','p','\\','N','a','m','e','s','p', + 'a','c','e','\0' }; + static BOOL CreateDesktopEnumList(IEnumIDList *list, DWORD dwFlags) { BOOL ret = TRUE; @@ -306,9 +321,7 @@ static BOOL CreateDesktopEnumList(IEnumIDList *list, DWORD dwFlags) /* create the pidl for This item */ ret = AddToEnumList(list, _ILCreateMyComputer()); - r = RegOpenKeyExA(HKEY_LOCAL_MACHINE, - "SOFTWARE\\Microsoft\\Windows\\" - "CurrentVersion\\explorer\\desktop\\NameSpace", + r = RegOpenKeyExW(HKEY_LOCAL_MACHINE, Desktop_NameSpaceW, 0, KEY_READ, &hkey); if (ret && ERROR_SUCCESS == r) { @@ -612,14 +625,21 @@ static HRESULT WINAPI ISF_Desktop_fnGetDisplayNameOf (IShellFolder2 * iface, else { /* get the "WantsFORPARSING" flag from the registry */ - char szRegPath[100]; + static const WCHAR clsidW[] = + { 'C','L','S','I','D','\\',0 }; + static const WCHAR shellfolderW[] = + { '\\','s','h','e','l','l','f','o','l','d','e','r',0 }; + static const WCHAR wantsForParsingW[] = + { 'W','a','n','t','s','F','o','r','P','a','r','s','i','n', + 'g',0 }; + WCHAR szRegPath[100]; LONG r; - lstrcpyA (szRegPath, "CLSID\\"); - SHELL32_GUIDToStringA (clsid, &szRegPath[6]); - lstrcatA (szRegPath, "\\shellfolder"); - r = SHGetValueA(HKEY_CLASSES_ROOT, szRegPath, - "WantsFORPARSING", NULL, NULL, NULL); + lstrcpyW (szRegPath, clsidW); + SHELL32_GUIDToStringW (clsid, &szRegPath[6]); + lstrcatW (szRegPath, shellfolderW); + r = SHGetValueW(HKEY_CLASSES_ROOT, szRegPath, + wantsForParsingW, NULL, NULL, NULL); if (r == ERROR_SUCCESS) bWantsForParsing = TRUE; else diff --git a/dlls/shell32/shfldr_fs.c b/dlls/shell32/shfldr_fs.c index cb720ab0730..348db84082c 100644 --- a/dlls/shell32/shfldr_fs.c +++ b/dlls/shell32/shfldr_fs.c @@ -677,6 +677,15 @@ IShellFolder_fnGetUIObjectOf (IShellFolder2 * iface, return hr; } +static const WCHAR AdvancedW[] = { 'S','O','F','T','W','A','R','E', + '\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\', + 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l', + 'o','r','e','r','\\','A','d','v','a','n','c','e','d',0 }; +static const WCHAR HideFileExtW[] = { 'H','i','d','e','F','i','l','e','E','x', + 't',0 }; +static const WCHAR NeverShowExtW[] = { 'N','e','v','e','r','S','h','o','w','E', + 'x','t',0 }; + void SHELL_FS_ProcessDisplayFilename(LPSTR szPath, DWORD dwFlags) { /*FIXME: MSDN also mentions SHGDN_FOREDITING which is not yet handled. */ @@ -687,10 +696,9 @@ void SHELL_FS_ProcessDisplayFilename(LPSTR szPath, DWORD dwFlags) DWORD dwDataSize = sizeof (DWORD); BOOL doHide = FALSE; /* The default value is FALSE (win98 at least) */ - if (!RegCreateKeyExA (HKEY_CURRENT_USER, - "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced", + if (!RegCreateKeyExW (HKEY_CURRENT_USER, AdvancedW, 0, 0, 0, KEY_ALL_ACCESS, 0, &hKey, 0)) { - if (!RegQueryValueExA (hKey, "HideFileExt", 0, 0, (LPBYTE) &dwData, + if (!RegQueryValueExW (hKey, HideFileExtW, 0, 0, (LPBYTE) &dwData, &dwDataSize)) doHide = dwData; @@ -701,18 +709,17 @@ void SHELL_FS_ProcessDisplayFilename(LPSTR szPath, DWORD dwFlags) LPSTR ext = PathFindExtensionA(szPath); if (ext) { - HKEY hkey; char classname[MAX_PATH]; LONG classlen = MAX_PATH; if (!RegQueryValueA(HKEY_CLASSES_ROOT, ext, classname, &classlen)) - if (!RegOpenKeyA(HKEY_CLASSES_ROOT, classname, &hkey)) { - if (!RegQueryValueExA(hkey, "NeverShowExt", 0, NULL, + if (!RegOpenKeyA(HKEY_CLASSES_ROOT, classname, &hKey)) { + if (!RegQueryValueExW(hKey, NeverShowExtW, 0, NULL, NULL, NULL)) doHide = TRUE; - RegCloseKey(hkey); + RegCloseKey(hKey); } } } @@ -813,9 +820,8 @@ static HRESULT WINAPI IShellFolder_fnSetNameOf (IShellFolder2 * iface, LPITEMIDLIST * pPidlOut) { _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface) - char szSrc[MAX_PATH], - szDest[MAX_PATH]; - int len; + WCHAR szSrc[MAX_PATH], szDest[MAX_PATH]; + LPWSTR ptr; BOOL bIsFolder = _ILIsFolder (ILFindLastID (pidl)); TRACE ("(%p)->(%p,pidl=%p,%s,%lu,%p)\n", This, hwndOwner, pidl, @@ -823,31 +829,29 @@ static HRESULT WINAPI IShellFolder_fnSetNameOf (IShellFolder2 * iface, /* build source path */ if (dwFlags & SHGDN_INFOLDER) { - strcpy (szSrc, This->sPathTarget); - PathAddBackslashA (szSrc); - len = strlen (szSrc); - _ILSimpleGetText (pidl, szSrc + len, MAX_PATH - len); + MultiByteToWideChar(CP_ACP, 0, This->sPathTarget, -1, szSrc, MAX_PATH); + ptr = PathAddBackslashW (szSrc); + if (ptr) + _ILSimpleGetTextW (pidl, ptr, MAX_PATH - (ptr - szSrc)); } else { /* FIXME: Can this work with a simple PIDL? */ - SHGetPathFromIDListA (pidl, szSrc); + SHGetPathFromIDListW (pidl, szSrc); } /* build destination path */ - strcpy (szDest, This->sPathTarget); - PathAddBackslashA (szDest); - len = strlen (szDest); - WideCharToMultiByte (CP_ACP, 0, lpName, -1, szDest + len, MAX_PATH - len, - NULL, NULL); - szDest[MAX_PATH - 1] = 0; - TRACE ("src=%s dest=%s\n", szSrc, szDest); - if (MoveFileA (szSrc, szDest)) { + MultiByteToWideChar(CP_ACP, 0, This->sPathTarget, -1, szDest, MAX_PATH); + ptr = PathAddBackslashW (szDest); + if (ptr) + lstrcpynW(ptr, lpName, MAX_PATH - (ptr - szDest)); + TRACE ("src=%s dest=%s\n", debugstr_w(szSrc), debugstr_w(szDest)); + if (MoveFileW (szSrc, szDest)) { HRESULT hr = S_OK; if (pPidlOut) - hr = _ILCreateFromPathA(szDest, pPidlOut); + hr = _ILCreateFromPathW(szDest, pPidlOut); SHChangeNotify (bIsFolder ? SHCNE_RENAMEFOLDER : SHCNE_RENAMEITEM, - SHCNF_PATHA, szSrc, szDest); + SHCNF_PATHW, szSrc, szDest); return hr; } diff --git a/dlls/shell32/shfldr_mycomp.c b/dlls/shell32/shfldr_mycomp.c index 5c16d7cdbbb..ef6a23eb206 100644 --- a/dlls/shell32/shfldr_mycomp.c +++ b/dlls/shell32/shfldr_mycomp.c @@ -569,8 +569,15 @@ static HRESULT WINAPI ISF_MyComputer_fnGetDisplayNameOf (IShellFolder2 *iface, { if (GET_SHGDN_FOR (dwFlags) == SHGDN_FORPARSING) { + static const WCHAR clsidW[] = + { 'C','L','S','I','D','\\',0 }; + static const WCHAR shellfolderW[] = + { '\\','s','h','e','l','l','f','o','l','d','e','r',0 }; + static const WCHAR wantsForParsingW[] = + { 'W','a','n','t','s','F','o','r','P','a','r','s','i','n', + 'g',0 }; int bWantsForParsing = FALSE; - char szRegPath[100]; + WCHAR szRegPath[100]; LONG r; /* @@ -584,11 +591,11 @@ static HRESULT WINAPI ISF_MyComputer_fnGetDisplayNameOf (IShellFolder2 *iface, * Get the "WantsFORPARSING" flag from the registry */ - lstrcpyA (szRegPath, "CLSID\\"); - SHELL32_GUIDToStringA (clsid, &szRegPath[6]); - lstrcatA (szRegPath, "\\shellfolder"); - r = SHGetValueA (HKEY_CLASSES_ROOT, szRegPath, - "WantsFORPARSING", NULL, NULL, NULL); + lstrcpyW (szRegPath, clsidW); + SHELL32_GUIDToStringW (clsid, &szRegPath[6]); + lstrcatW (szRegPath, shellfolderW); + r = SHGetValueW (HKEY_CLASSES_ROOT, szRegPath, + wantsForParsingW, NULL, NULL, NULL); if (r == ERROR_SUCCESS) bWantsForParsing = TRUE;