msvfw: fix enumeration of installed codecs

Peter Beutner p.beutner at gmx.net
Fri Jun 9 09:30:48 CDT 2006


- Fix enumeration to retrieve registry values instead of subkeys.(Because that's how
  they are stored, no idea how the original code was supposed to work?)
- Remove checking for '=' char. That's only needed for entries in system.ini.
- Use compare_fourcc instead of just comparing the DWORD values because FOURCCs are
  case-independent.

---

 dlls/msvfw32/msvideo_main.c |   34 +++++++++++++++++++---------------
 1 files changed, 19 insertions(+), 15 deletions(-)

061e276bf6b03513fb071e009d30ccafa2d92cf6
diff --git a/dlls/msvfw32/msvideo_main.c b/dlls/msvfw32/msvideo_main.c
index 4044ec5..b67e077 100644
--- a/dlls/msvfw32/msvideo_main.c
+++ b/dlls/msvfw32/msvideo_main.c
@@ -103,14 +103,12 @@ static int compare_fourcc(DWORD fcc1, DW
   return strncasecmp(fcc_str1, fcc_str2, 4);
 }
 
-typedef BOOL (*enum_handler_t)(const char*, int, void*);
+typedef BOOL (*enum_handler_t)(const char*, const char*, int, void*);
 
 static BOOL enum_drivers(DWORD fccType, enum_handler_t handler, void* param)
 {
     CHAR buf[2048], fccTypeStr[5], *s;
     DWORD i, cnt = 0, bufLen, lRet;
-    BOOL result = FALSE;
-    FILETIME lastWrite;
     HKEY hKey;
 
     fourcc_to_string(fccTypeStr, fccType);
@@ -120,19 +118,24 @@ static BOOL enum_drivers(DWORD fccType, 
     lRet = RegOpenKeyExA(HKEY_LOCAL_MACHINE, HKLM_DRIVERS32, 0, KEY_QUERY_VALUE, &hKey);
     if (lRet == ERROR_SUCCESS) 
     {
-	DWORD numkeys;
-	RegQueryInfoKeyA( hKey, 0, 0, 0, &numkeys, 0, 0, 0, 0, 0, 0, 0);
+	DWORD numkeys, nlen = 128;
+	CHAR dllname[128];
+
+	RegQueryInfoKeyA( hKey, 0, 0, 0, 0, 0, 0, &numkeys, 0, 0, 0, 0);
 	for (i = 0; i < numkeys; i++) 
 	{
 	    bufLen = sizeof(buf) / sizeof(buf[0]);
-	    lRet = RegEnumKeyExA(hKey, i, buf, &bufLen, 0, 0, 0, &lastWrite);
+	    lRet = RegEnumValueA(hKey, i, buf, &bufLen, 0, 0, (LPBYTE)dllname, &nlen);
 	    if (lRet != ERROR_SUCCESS) continue;
-	    if (strncasecmp(buf, fccTypeStr, 5) || buf[9] != '=') continue;
-	    if ((result = handler(buf, cnt++, param))) break;
+	    TRACE("got(registry): %s=%s\n", buf,dllname);
+	    if (strncasecmp(buf, fccTypeStr, 5)) continue;
+	    if ( handler(buf, dllname, cnt++, param) ) {
+	        RegCloseKey( hKey );
+	        return TRUE;
+	    }
 	}
     	RegCloseKey( hKey );
     }
-    if (result) return result;
 
     /* if that didn't work, go through the values in system.ini */
     if (GetPrivateProfileSectionA("drivers32", buf, sizeof(buf), "system.ini")) 
@@ -141,11 +144,12 @@ static BOOL enum_drivers(DWORD fccType, 
 	{
             TRACE("got %s\n", s);
 	    if (strncasecmp(s, fccTypeStr, 5) || s[9] != '=') continue;
-	    if ((result = handler(s, cnt++, param))) break;
+	    if ( handler(s, s + 10, cnt++, param) ) 
+	        return TRUE;            
 	}
     }
 
-    return result;
+    return FALSE;
 }
 
 /******************************************************************
@@ -172,13 +176,13 @@ DWORD WINAPI VideoForWindowsVersion(void
     return 0x040003B6; /* 4.950 */
 }
 
-static BOOL ICInfo_enum_handler(const char *drv, int nr, void *param)
+static BOOL ICInfo_enum_handler(const char *drv, const char* dll, int nr, void *param)
 {
     ICINFO *lpicinfo = (ICINFO *)param;
     DWORD fccHandler = mmioStringToFOURCCA(drv + 5, 0);
 
     /* exact match of fccHandler or nth driver found */
-    if ((lpicinfo->fccHandler != nr) && (lpicinfo->fccHandler != fccHandler))
+    if ((lpicinfo->fccHandler != nr) && (compare_fourcc(lpicinfo->fccHandler,fccHandler)) )        
 	return FALSE;
 
     lpicinfo->fccHandler = fccHandler;
@@ -187,7 +191,7 @@ static BOOL ICInfo_enum_handler(const ch
     lpicinfo->dwVersionICM = ICVERSION;
     lpicinfo->szName[0] = 0;
     lpicinfo->szDescription[0] = 0;
-    MultiByteToWideChar(CP_ACP, 0, drv + 10, -1, lpicinfo->szDriver, 
+    MultiByteToWideChar(CP_ACP, 0, dll, -1, lpicinfo->szDriver, 
 			sizeof(lpicinfo->szDriver)/sizeof(WCHAR));
 
     return TRUE;
@@ -518,7 +522,7 @@ static HIC try_driver(driver_info_t *inf
     return 0;
 }
 
-static BOOL ICLocate_enum_handler(const char *drv, int nr, void *param)
+static BOOL ICLocate_enum_handler(const char *drv, const char* dll, int nr, void *param)
 {
     driver_info_t *info = (driver_info_t *)param;
     info->fccHandler = mmioStringToFOURCCA(drv + 5, 0);
-- 
1.3.3




More information about the wine-patches mailing list