[MSACM] Look up driver info in the registry as well

Dimitrie O. Paun dpaun at rogers.com
Tue Jun 29 00:43:57 CDT 2004


ChangeLog
    Look up driver info in the registry as well as in system.ini.


Index: dlls/msacm/Makefile.in
===================================================================
RCS file: /var/cvs/wine/dlls/msacm/Makefile.in,v
retrieving revision 1.25
diff -u -r1.25 Makefile.in
--- dlls/msacm/Makefile.in	3 May 2004 20:17:43 -0000	1.25
+++ dlls/msacm/Makefile.in	4 May 2004 05:04:00 -0000
@@ -5,6 +5,7 @@
 MODULE    = msacm32.dll
 IMPORTS   = winmm user32 advapi32 kernel32
 ALTNAMES  = msacm.dll
+EXTRALIBS = $(LIBUNICODE)
 
 SPEC_SRCS16 = $(ALTNAMES:.dll=.spec)
 
Index: dlls/msacm/internal.c
===================================================================
RCS file: /var/cvs/wine/dlls/msacm/internal.c,v
retrieving revision 1.18
diff -u -r1.18 internal.c
--- dlls/msacm/internal.c	20 Apr 2004 00:34:53 -0000	1.18
+++ dlls/msacm/internal.c	27 Apr 2004 13:39:46 -0000
@@ -283,49 +283,51 @@
  */
 void MSACM_RegisterAllDrivers(void)
 {
-    LPWSTR pszBuffer;
-    DWORD dwBufferLength;
     static const WCHAR msacm32[] = {'m','s','a','c','m','3','2','.','d','l','l','\0'};
     static const WCHAR msacmW[] = {'M','S','A','C','M','.'};
     static const WCHAR drv32[] = {'d','r','i','v','e','r','s','3','2','\0'};
     static const WCHAR sys[] = {'s','y','s','t','e','m','.','i','n','i','\0'};
+    static const WCHAR drvkey[] = {'S','o','f','t','w','a','r','e','\\',
+				   'M','i','c','r','o','s','o','f','t','\\',
+				   'W','i','n','d','o','w','s',' ','N','T','\\',
+				   'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
+				   'D','r','i','v','e','r','s','3','2','\0'};
+    DWORD i, cnt = 0, bufLen, lRet;
+    WCHAR buf[2048], *name, *s;
+    FILETIME lastWrite;
+    HKEY hKey;
+
+    /* FIXME: What if the user edits system.ini while the program is running?
+     * Does Windows handle that?  */
+    if (MSACM_pFirstACMDriverID) return;
+
+    lRet = RegOpenKeyExW(HKEY_LOCAL_MACHINE, drvkey, 0, KEY_QUERY_VALUE, &hKey);
+    if (lRet == ERROR_SUCCESS) {
+	RegQueryInfoKeyW( hKey, 0, 0, 0, &cnt, 0, 0, 0, 0, 0, 0, 0);
+	for (i = 0; i < cnt; i++) {
+	    bufLen = sizeof(buf) / sizeof(buf[0]);
+	    lRet = RegEnumKeyExW(hKey, i, buf, &bufLen, 0, 0, 0, &lastWrite);
+	    if (lRet != ERROR_SUCCESS) continue;
+	    if (strncmpiW(buf, msacmW, sizeof(msacmW)/sizeof(msacmW[0]))) continue;
+	    if (!(name = strchrW(buf, '='))) continue;
+	    *name = 0;
+	    MSACM_RegisterDriver(buf, name + 1, 0);
+	}
+    	RegCloseKey( hKey );
+    }
 
-    /* FIXME
-     *  What if the user edits system.ini while the program is running?
-     *  Does Windows handle that?
-     */
-    if (MSACM_pFirstACMDriverID)
-	return;
-
-    /* FIXME: Does not work! How do I determine the section length? */
-    dwBufferLength = 1024;
-/* EPP 	GetPrivateProfileSectionA("drivers32", NULL, 0, "system.ini"); */
-
-    pszBuffer = (LPWSTR) HeapAlloc(MSACM_hHeap, 0, dwBufferLength * sizeof(WCHAR));
-    if (GetPrivateProfileSectionW(drv32, pszBuffer, dwBufferLength, sys))
+    if (GetPrivateProfileSectionW(drv32, buf, sizeof(buf)/sizeof(buf[0]), sys))
     {
-	LPWSTR s = pszBuffer, s2;
-
-	while (*s)
-        {
-            CharUpperBuffW(s, 6);
-            if (memcmp(s, msacmW, 6 * sizeof(WCHAR)) == 0)
-            {
-                s2 = s;
-		while (*s2 != '\0' && *s2 != '=') s2++;
-		if (*s2)
-                {
-		    *s2 = '\0';
-		    MSACM_RegisterDriver(s, s2 + 1, 0);
-		    *s2 = '=';
-		}
-	    }
-	    s += strlenW(s) + 1; /* Either next char or \0 */
+	for(s = buf; *s;  s += strlenW(s) + 1)
+	{
+	    if (strncmpiW(s, msacmW, sizeof(msacmW)/sizeof(msacmW[0]))) continue;
+	    if (!(name = strchrW(s, '='))) continue;
+	    *name = 0;
+	    MSACM_RegisterDriver(s, name + 1, 0);
+	    *name = '=';
 	}
     }
 
-    HeapFree(MSACM_hHeap, 0, pszBuffer);
-
     MSACM_RegisterDriver(msacm32, msacm32, 0);
 }
 



More information about the wine-patches mailing list