shell execute

Aric Stewart aric at codeweavers.com
Tue Mar 7 09:47:54 CST 2006


the lpClass parameter for ShellExecute can be an extention instead of 
just a file type. This patch handled that situation.

-------------- next part --------------
 dlls/shell32/classes.c |   42 +++++++++++++++++++++++++++++++++++++++---
 1 files changed, 39 insertions(+), 3 deletions(-)

applies-to: ddd356ea15f060ce5bdba07ee52d2cc25f836591
ee72c8bcc88c434c3024f51f55e63762f7d94577
diff --git a/dlls/shell32/classes.c b/dlls/shell32/classes.c
index 440809c..42433ad 100644
--- a/dlls/shell32/classes.c
+++ b/dlls/shell32/classes.c
@@ -118,6 +118,43 @@ BOOL HCR_MapTypeToValueA(LPCSTR szExtens
 }
 
 
+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 )
 {
         static const WCHAR swShell[] = {'s','h','e','l','l','\\',0};
@@ -126,10 +163,9 @@ BOOL HCR_GetExecuteCommandW( HKEY hkeyCl
 
 	TRACE("%p %s %s %p\n", hkeyClass, debugstr_w(szClass), debugstr_w(szVerb), szDest);
 
-	if (szClass)
-            RegOpenKeyExW(HKEY_CLASSES_ROOT, szClass, 0, 0x02000000, &hkeyClass);
+    hkeyClass = _GetClassKey(szClass);
 
-        if (hkeyClass)
+    if (hkeyClass)
 	{
 	    WCHAR sTemp[MAX_PATH];
 	    lstrcpyW(sTemp, swShell);
---
0.99.9i


More information about the wine-patches mailing list