Paul Vriens : shell32/tests: Cope with systems lacking SHGetSpecialFolderPath.

Alexandre Julliard julliard at winehq.org
Mon Nov 30 10:42:43 CST 2009


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

Author: Paul Vriens <Paul.Vriens.Wine at gmail.com>
Date:   Thu Nov 26 20:20:08 2009 +0100

shell32/tests: Cope with systems lacking SHGetSpecialFolderPath.

---

 dlls/shell32/tests/progman_dde.c |   53 +++++++++++++++++++++++++-------------
 1 files changed, 35 insertions(+), 18 deletions(-)

diff --git a/dlls/shell32/tests/progman_dde.c b/dlls/shell32/tests/progman_dde.c
index 6ba22ed..8902d90 100644
--- a/dlls/shell32/tests/progman_dde.c
+++ b/dlls/shell32/tests/progman_dde.c
@@ -89,23 +89,47 @@ static void init_strings(void)
 {
     HKEY key;
     DWORD fullpath = 0;
-    DWORD size = sizeof(DWORD);
+    DWORD size;
     char startup[MAX_PATH];
 
-    if (!pSHGetSpecialFolderPathA)
-        return;
-
-    /* FIXME: On Vista+ we should only use CSIDL_PROGRAMS */
-    pSHGetSpecialFolderPathA(NULL, Programs, CSIDL_PROGRAMS, FALSE);
-    if (!pSHGetSpecialFolderPathA(NULL, CommonPrograms, CSIDL_COMMON_PROGRAMS, FALSE))
+    if (pSHGetSpecialFolderPathA)
     {
-        /* Win9x */
-        lstrcpyA(CommonPrograms, Programs);
+        /* FIXME: On Vista+ we should only use CSIDL_PROGRAMS */
+        pSHGetSpecialFolderPathA(NULL, Programs, CSIDL_PROGRAMS, FALSE);
+        if (!pSHGetSpecialFolderPathA(NULL, CommonPrograms, CSIDL_COMMON_PROGRAMS, FALSE))
+        {
+            /* Win9x */
+            lstrcpyA(CommonPrograms, Programs);
+        }
+        pSHGetSpecialFolderPathA(NULL, startup, CSIDL_STARTUP, FALSE);
+        lstrcpyA(Startup, (strrchr(startup, '\\') + 1));
+    }
+    else
+    {
+        LONG res;
+
+        /* Older Win9x and NT4 */
+        RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", &key);
+        size = sizeof(CommonPrograms);
+        res = RegQueryValueExA(key, "Common Programs", NULL, NULL, (LPBYTE)&CommonPrograms, &size);
+        RegCloseKey(key);
+        if (res != ERROR_SUCCESS)
+        {
+            /* Win9x */
+            lstrcpyA(CommonPrograms, Programs);
+        }
+
+        RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", &key);
+        size = sizeof(Programs);
+        RegQueryValueExA(key, "Programs", NULL, NULL, (LPBYTE)&Programs, &size);
+        size = sizeof(startup);
+        RegQueryValueExA(key, "Startup", NULL, NULL, (LPBYTE)&startup, &size);
+        lstrcpyA(Startup, (strrchr(startup, '\\') + 1));
+        RegCloseKey(key);
     }
-    pSHGetSpecialFolderPathA(NULL, startup, CSIDL_STARTUP, FALSE);
-    lstrcpyA(Startup, (strrchr(startup, '\\') + 1));
 
     RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CabinetState", &key);
+    size = sizeof(DWORD);
     RegQueryValueExA(key, "FullPath", NULL, NULL, (LPBYTE)&fullpath, &size);
     RegCloseKey(key);
     if (fullpath == 1)
@@ -291,9 +315,6 @@ static void CheckFileExistsInProgramGroups(const char *nameToCheck, int shouldEx
     DWORD attributes;
     int len;
 
-    if (!pSHGetSpecialFolderPathA)
-        return;
-
     path = HeapAlloc(GetProcessHeap(), 0, MAX_PATH);
     if (path != NULL)
     {
@@ -580,10 +601,6 @@ START_TEST(progman_dde)
     init_function_pointers();
     init_strings();
 
-    /* Only report this once */
-    if (!pSHGetSpecialFolderPathA)
-        win_skip("SHGetSpecialFolderPathA is not available\n");
-
     /* Initialize DDE Instance */
     err = DdeInitialize(&instance, DdeCallback, APPCMD_CLIENTONLY, 0);
     ok (err == DMLERR_NO_ERROR, "DdeInitialize Error %s\n", GetStringFromError(err));




More information about the wine-cvs mailing list