From 5a538105d174b9bb6fc4451f1562bc8785609f50 Mon Sep 17 00:00:00 2001
From: Guy Albertelli <galberte@neo.lrun.com>
Date: Wed, 3 Oct 2001 18:42:16 +0000
Subject: [PATCH] Fix SHAddToRecentDocs code to properly handle native Comctl32
 and missing policies location.

---
 dlls/shell32/shell32_main.c | 10 +++++-----
 dlls/shell32/shellord.c     | 21 ++++++++++++++-------
 2 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/dlls/shell32/shell32_main.c b/dlls/shell32/shell32_main.c
index 0fdfb491563..8a0e4dd37b3 100644
--- a/dlls/shell32/shell32_main.c
+++ b/dlls/shell32/shell32_main.c
@@ -1007,11 +1007,11 @@ BOOL WINAPI Shell32LibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
 	    pDPA_DeletePtr=(void*)GetProcAddress(hComctl32, (LPCSTR)336L);
 	    pDPA_Sort=(void*)GetProcAddress(hComctl32, (LPCSTR)338L);
 	    pDPA_Search=(void*)GetProcAddress(hComctl32, (LPCSTR)339L);
-	    pCreateMRUListA=(void*)GetProcAddress(hComctl32, "CreateMRUListA");
-	    pFreeMRUListA=(void*)GetProcAddress(hComctl32, "FreeMRUList");
-	    pAddMRUData=(void*)GetProcAddress(hComctl32, "AddMRUData");
-	    pFindMRUData=(void*)GetProcAddress(hComctl32, "FindMRUData");
-	    pEnumMRUListA=(void*)GetProcAddress(hComctl32, "EnumMRUListA");
+	    pCreateMRUListA=(void*)GetProcAddress(hComctl32, (LPCSTR)151L /*"CreateMRUListA"*/);
+	    pFreeMRUListA=(void*)GetProcAddress(hComctl32, (LPCSTR)152L /*"FreeMRUList"*/);
+	    pAddMRUData=(void*)GetProcAddress(hComctl32, (LPCSTR)167L /*"AddMRUData"*/);
+	    pFindMRUData=(void*)GetProcAddress(hComctl32, (LPCSTR)169L /*"FindMRUData"*/);
+	    pEnumMRUListA=(void*)GetProcAddress(hComctl32, (LPCSTR)154L /*"EnumMRUListA"*/);
 
 	    /* initialize the common controls */
 	    if (pDLLInitComctl)
diff --git a/dlls/shell32/shellord.c b/dlls/shell32/shellord.c
index ca28b662684..91bfbf80f0b 100644
--- a/dlls/shell32/shellord.c
+++ b/dlls/shell32/shellord.c
@@ -463,7 +463,8 @@ static INT SHADD_get_policy(LPSTR policy, LPDWORD type, LPVOID buffer, LPDWORD l
 	if (RegOpenKeyExA(HKEY_CURRENT_USER,
 			  "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",
 			  0, KEY_READ, &Policy_basekey)) {
-	    ERR("No Explorer Policies location\n");
+	    TRACE("No Explorer Policies location exists. Policy wanted=%s\n",
+		  policy);
 	    *len = 0;
 	    return ERROR_FILE_NOT_FOUND;
 	}
@@ -636,11 +637,12 @@ typedef struct tagCREATEMRULIST
      *        and the close should be done during the _DETACH. The resulting
      *        key is stored in the DLL global data.
      */
-    RegOpenKeyExA(HKEY_CURRENT_USER,
-		  "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
-		  0,
-		  KEY_READ,
-		  &HCUbasekey);
+    if (RegCreateKeyExA(HKEY_CURRENT_USER,
+			"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
+			0, 0, 0, KEY_READ, 0, &HCUbasekey, 0)) {
+	ERR("Failed to create 'Software\\Microsoft\\Windows\\CurrentVersion\\Explorer'\n");
+	return 0;
+    }
 
     /* Get path to user's "Recent" directory
      */
@@ -650,12 +652,17 @@ typedef struct tagCREATEMRULIST
 	    SHGetPathFromIDListA(pidl, link_dir);
 	    IMalloc_Free(ppM, pidl);
 	}
+	else {
+	    /* serious issues */
+	    link_dir[0] = 0;
+	    ERR("serious issues 1\n");
+	}
 	IMalloc_Release(ppM);
     }
     else {
 	/* serious issues */
 	link_dir[0] = 0;
-	ERR("serious issues\n");
+	ERR("serious issues 2\n");
     }
     TRACE("Users Recent dir %s\n", link_dir);
 
-- 
GitLab