Paul Vriens : shell32/tests: Cope with non-English Vista+ and short names in the title bar of explorer windows .

Alexandre Julliard julliard at winehq.org
Tue Dec 8 11:10:38 CST 2009


Module: wine
Branch: master
Commit: b965a5f0e0d20658a7240767f6a236089487e0fa
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=b965a5f0e0d20658a7240767f6a236089487e0fa

Author: Paul Vriens <Paul.Vriens.Wine at gmail.com>
Date:   Tue Dec  8 14:54:53 2009 +0100

shell32/tests: Cope with non-English Vista+ and short names in the title bar of explorer windows.

---

 dlls/shell32/tests/progman_dde.c |   31 +++++++++++++++++++++++++++++--
 1 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/dlls/shell32/tests/progman_dde.c b/dlls/shell32/tests/progman_dde.c
index 7e6c874..610fb01 100644
--- a/dlls/shell32/tests/progman_dde.c
+++ b/dlls/shell32/tests/progman_dde.c
@@ -66,6 +66,7 @@
 
 #define DDE_TEST_NUMMASK           0x0000ffff
 
+static HRESULT (WINAPI *pSHGetLocalizedName)(LPCWSTR, LPWSTR, UINT, int *);
 static BOOL (WINAPI *pSHGetSpecialFolderPathA)(HWND, LPSTR, int, BOOL);
 static BOOL (WINAPI *pReadCabinetState)(CABINETSTATE *, int);
 
@@ -74,6 +75,7 @@ static void init_function_pointers(void)
     HMODULE hmod;
 
     hmod = GetModuleHandleA("shell32.dll");
+    pSHGetLocalizedName = (void*)GetProcAddress(hmod, "SHGetLocalizedName");
     pSHGetSpecialFolderPathA = (void*)GetProcAddress(hmod, "SHGetSpecialFolderPathA");
     pReadCabinetState = (void*)GetProcAddress(hmod, "ReadCabinetState");
     if (!pReadCabinetState)
@@ -102,7 +104,7 @@ static void init_strings(void)
             /* Win9x */
             lstrcpyA(CommonPrograms, Programs);
         }
-        if (GetProcAddress(GetModuleHandleA("shell32.dll"), "SHGetKnownFolderPath"))
+        if (pSHGetLocalizedName)
         {
             /* Vista and higher use CSIDL_PROGRAMS for these tests.
              * Wine doesn't have SHGetKnownFolderPath yet but should most likely follow
@@ -154,7 +156,32 @@ static void init_strings(void)
     }
     else
     {
-        lstrcpyA(StartupTitle, Startup);
+        /* Vista has the nice habit of displaying the full path in English
+         * and the short one localized. CSIDL_STARTUP on Vista gives us the
+         * English version so we have to 'translate' this one.
+         *
+         * MSDN claims it should be used for files not folders but this one
+         * suits our purposes just fine.
+         */
+        if (pSHGetLocalizedName)
+        {
+            WCHAR startupW[MAX_PATH];
+            WCHAR module[MAX_PATH];
+            WCHAR module_expanded[MAX_PATH];
+            WCHAR localized[MAX_PATH];
+            int id;
+
+            MultiByteToWideChar(CP_ACP, 0, startup, -1, startupW, sizeof(startupW)/sizeof(WCHAR));
+            pSHGetLocalizedName(startupW, module, MAX_PATH, &id);
+            ExpandEnvironmentStringsW(module, module_expanded, MAX_PATH);
+            LoadStringW(GetModuleHandleW(module_expanded), id, localized, MAX_PATH);
+
+            WideCharToMultiByte(CP_ACP, 0, localized, -1, StartupTitle, sizeof(StartupTitle), NULL, NULL);
+        }
+        else
+        {
+            lstrcpyA(StartupTitle, (strrchr(startup, '\\') + 1));
+        }
     }
 }
 




More information about the wine-cvs mailing list