shell32: Allow ShellExecute to accept file extensions for lpClass.

Michael Moss mmoss at google.com
Thu Apr 17 12:33:37 CDT 2008


[originally a Picasa patch by Aric Stewart]
the lpClass parameter for ShellExecute can be an extention instead of just a
file type. This patch handles that situation.
---
 dlls/shell32/classes.c |   44 ++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 40 insertions(+), 4 deletions(-)

diff --git a/dlls/shell32/classes.c b/dlls/shell32/classes.c
index e5fab4d..5c05466 100644
--- a/dlls/shell32/classes.c
+++ b/dlls/shell32/classes.c
@@ -174,6 +174,43 @@ BOOL HCR_GetDefaultVerbW( HKEY hkeyClass, LPCWSTR szVerb, LPWSTR szDest, DWORD l
 	return FALSE;
 }
 
+static HKEY _GetClassKey(LPCWSTR szClass)
+{
+    HKEY hkeyClass = 0;
+    LPWSTR ext;
+
+    ext = PathFindExtensionW( szClass);
+    if (!ext)
+        RegOpenKeyExW(HKEY_CLASSES_ROOT, szClass, 0, 0x02000000, &hkeyClass);
+    else
+    {
+        HKEY hkey;
+        DWORD type=0, sz = 0;
+        LONG r;
+
+        TRACE("ext = %s\n", debugstr_w( ext ) );
+
+        r = RegOpenKeyW( HKEY_CLASSES_ROOT, ext, &hkey );
+        if (r != ERROR_SUCCESS )
+            return 0;
+
+        r = RegQueryValueExW( hkey, NULL, 0, &type, NULL, &sz );
+        if ( r == ERROR_SUCCESS && type == REG_SZ )
+        {
+            LPWSTR cls;
+            sz += sizeof (WCHAR);
+            cls = HeapAlloc( GetProcessHeap(), 0, sz );
+            cls[0] = 0;
+            RegQueryValueExW( hkey, NULL, 0, &type, (LPBYTE) cls, &sz );
+            RegOpenKeyW( HKEY_CLASSES_ROOT, cls, &hkeyClass );
+            HeapFree(GetProcessHeap(),0,cls);
+        }
+
+        RegCloseKey( hkey );
+    }
+    return hkeyClass;
+}
+
 BOOL HCR_GetExecuteCommandW( HKEY hkeyClass, LPCWSTR szClass, LPCWSTR szVerb, LPWSTR szDest, DWORD len )
 {
 	WCHAR sTempVerb[MAX_PATH];
@@ -181,8 +218,8 @@ BOOL HCR_GetExecuteCommandW( HKEY hkeyClass, LPCWSTR szClass, LPCWSTR szVerb, LP
 
 	TRACE("%p %s %s %p\n", hkeyClass, debugstr_w(szClass), debugstr_w(szVerb), szDest);
 
-	if (szClass)
-            RegOpenKeyExW(HKEY_CLASSES_ROOT, szClass, 0, KEY_READ, &hkeyClass);
+        hkeyClass = _GetClassKey(szClass);
+
         if (!hkeyClass)
             return FALSE;
         ret = FALSE;
@@ -195,8 +232,7 @@ BOOL HCR_GetExecuteCommandW( HKEY hkeyClass, LPCWSTR szClass, LPCWSTR szVerb, LP
             lstrcatW(sTemp, swCommand);
             ret = (ERROR_SUCCESS == SHGetValueW(hkeyClass, sTemp, NULL, NULL, szDest, &len));
         }
-        if (szClass)
-            RegCloseKey(hkeyClass);
+        RegCloseKey(hkeyClass);
 
 	TRACE("-- %s\n", debugstr_w(szDest) );
 	return ret;
-- 
1.5.3.GIT




More information about the wine-patches mailing list