On November 22, 2003 03:02 am, Eric Pouech wrote: > I won't have too much time to look at this in details right now, so if > someone wants to jump in, I'll be happy to give him (her ?) a hand. To be honest, My interest in doing this work is to get rid of system.ini from the Wine tree. While I agree that there's more to do, it's just not up my alley :) So, this version of the patch still maintains support for system.ini, just like the old code does, but it also adds support for registry, which should allow us to move stuff there. So here it goes again, I hope this time it's acceptable. ChangeLog Move MCI settings from system.ini to the registry. Simplify code, make the configuration values dynamic. Index: documentation/samples/system.ini =================================================================== RCS file: /var/cvs/wine/documentation/samples/system.ini,v retrieving revision 1.12 diff -u -r1.12 system.ini --- documentation/samples/system.ini 9 Nov 2003 00:31:35 -0000 1.12 +++ documentation/samples/system.ini 22 Nov 2003 02:29:17 -0000 @@ -1,13 +1,3 @@ -[mci] -MPEGVideo=mciqtz.drv -MPEGVideo2=mciqtz.drv -avivideo=mciavi.drv -cdaudio=mcicda.drv -sequencer=mciseq.drv -vcr=mcivisca.drv -; videodisc=mcipionr.drv -waveaudio=mciwave.drv - [drivers32] MSACM.imaadpcm=imaadp32.acm MSACM.msadpcm=msadp32.acm Index: winedefault.reg =================================================================== RCS file: /var/cvs/wine/winedefault.reg,v retrieving revision 1.79 diff -u -r1.79 winedefault.reg --- winedefault.reg 18 Nov 2003 20:40:59 -0000 1.79 +++ winedefault.reg 22 Nov 2003 02:31:47 -0000 @@ -48,6 +48,16 @@ # # WinMM config # +[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\MCI] +"MPEGVideo"="mciqtz.drv" +"MPEGVideo2"="mciqtz.drv" +"avivideo"="mciavi.drv" +"cdaudio"="mcicda.drv" +"sequencer"="mciseq.drv" +"vcr"="mcivisca.drv" +# "videodisc"="mcipionr.drv" +"waveaudio"="mciwave.drv" + [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\MCI Extensions] "cda"="cdaudio" "mid"="sequencer" Index: dlls/winmm/driver.c =================================================================== RCS file: /var/cvs/wine/dlls/winmm/driver.c,v retrieving revision 1.25 diff -u -r1.25 driver.c --- dlls/winmm/driver.c 9 Nov 2003 01:19:59 -0000 1.25 +++ dlls/winmm/driver.c 22 Nov 2003 17:33:25 -0000 @@ -29,12 +29,15 @@ #include "wingdi.h" #include "winuser.h" #include "winnls.h" +#include "winreg.h" #include "mmddk.h" #include "winemm.h" #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(driver); +#define HKLM_BASE "Software\\Microsoft\\Windows NT\\CurrentVersion" + static LPWINE_DRIVER lpDrvItemList /* = NULL */; WINE_MMTHREAD* (*pFnGetMMThread16)(UINT16 h) /* = NULL */; @@ -206,7 +209,21 @@ */ BOOL DRIVER_GetLibName(LPCSTR keyName, LPCSTR sectName, LPSTR buf, int sz) { - /* should also do some registry diving */ + HKEY hKey, hSecKey; + DWORD bufLen, lRet; + + lRet = RegOpenKeyExA(HKEY_LOCAL_MACHINE, HKLM_BASE, 0, KEY_QUERY_VALUE, &hKey); + if (lRet == ERROR_SUCCESS) { + lRet = RegOpenKeyExA(hKey, sectName, 0, KEY_QUERY_VALUE, &hSecKey); + if (lRet == ERROR_SUCCESS) { + lRet = RegQueryValueExA(hSecKey, keyName, 0, 0, buf, &bufLen); + RegCloseKey( hSecKey ); + } + RegCloseKey( hKey ); + } + if (lRet == ERROR_SUCCESS) return TRUE; + /* default to system.ini if we can't find it in the registry, + * to support native installations where system.ini is still used */ return GetPrivateProfileStringA(sectName, keyName, "", buf, sz, "SYSTEM.INI"); } Index: dlls/winmm/mci.c =================================================================== RCS file: /var/cvs/wine/dlls/winmm/mci.c,v retrieving revision 1.48 diff -u -r1.48 mci.c --- dlls/winmm/mci.c 15 Oct 2003 20:49:29 -0000 1.48 +++ dlls/winmm/mci.c 24 Nov 2003 17:03:45 -0000 @@ -44,9 +44,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(mci); -static int MCI_InstalledCount; -static LPSTR MCI_lpInstallNames /* = NULL */; - WINMM_MapType (*pFnMciMapMsg16To32A) (WORD,WORD,DWORD*) /* = NULL */; WINMM_MapType (*pFnMciUnMapMsg16To32A)(WORD,WORD,DWORD) /* = NULL */; WINMM_MapType (*pFnMciMapMsg32ATo16) (WORD,WORD,DWORD,DWORD*) /* = NULL */; @@ -55,6 +52,9 @@ /* First MCI valid device ID (0 means error) */ #define MCI_MAGIC 0x0001 +/* MCI settings */ +#define HKLM_MCI "Software\\Microsoft\\Windows NT\\CurrentVersion\\MCI" + /* dup a string and uppercase it */ inline static LPSTR str_dup_upper( LPCSTR str ) { @@ -1423,6 +1423,9 @@ { DWORD ret = MCIERR_INVALID_DEVICE_ID; LPWINE_MCIDRIVER wmd; + HKEY hKey; + CHAR buf[2048], *s = buf; + DWORD cnt = 0; if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK; @@ -1431,41 +1434,39 @@ switch (dwFlags & ~MCI_SYSINFO_OPEN) { case MCI_SYSINFO_QUANTITY: - { - DWORD cnt = 0; - - if (lpParms->wDeviceType < MCI_DEVTYPE_FIRST || - lpParms->wDeviceType > MCI_DEVTYPE_LAST) { - if (dwFlags & MCI_SYSINFO_OPEN) { - TRACE("MCI_SYSINFO_QUANTITY: # of open MCI drivers\n"); - EnterCriticalSection(&WINMM_IData->cs); - for (wmd = WINMM_IData->lpMciDrvs; wmd; wmd = wmd->lpNext) { - cnt++; - } - LeaveCriticalSection(&WINMM_IData->cs); - } else { - TRACE("MCI_SYSINFO_QUANTITY: # of installed MCI drivers\n"); - cnt = MCI_InstalledCount; + if (lpParms->wDeviceType < MCI_DEVTYPE_FIRST || lpParms->wDeviceType > MCI_DEVTYPE_LAST) { + if (dwFlags & MCI_SYSINFO_OPEN) { + TRACE("MCI_SYSINFO_QUANTITY: # of open MCI drivers\n"); + EnterCriticalSection(&WINMM_IData->cs); + for (wmd = WINMM_IData->lpMciDrvs; wmd; wmd = wmd->lpNext) { + cnt++; } + LeaveCriticalSection(&WINMM_IData->cs); } else { - if (dwFlags & MCI_SYSINFO_OPEN) { - TRACE("MCI_SYSINFO_QUANTITY: # of open MCI drivers of type %u\n", - lpParms->wDeviceType); - EnterCriticalSection(&WINMM_IData->cs); - for (wmd = WINMM_IData->lpMciDrvs; wmd; wmd = wmd->lpNext) { - if (wmd->wType == lpParms->wDeviceType) - cnt++; - } - LeaveCriticalSection(&WINMM_IData->cs); - } else { - TRACE("MCI_SYSINFO_QUANTITY: # of installed MCI drivers of type %u\n", - lpParms->wDeviceType); - FIXME("Don't know how to get # of MCI devices of a given type\n"); - cnt = 1; + TRACE("MCI_SYSINFO_QUANTITY: # of installed MCI drivers\n"); + if (RegOpenKeyExA( HKEY_LOCAL_MACHINE, HKLM_MCI, + 0, KEY_QUERY_VALUE, &hKey ) == ERROR_SUCCESS) { + RegQueryInfoKeyA( hKey, 0, 0, 0, &cnt, 0, 0, 0, 0, 0, 0, 0); + RegCloseKey( hKey ); } + if (GetPrivateProfileStringA("mci", 0, "", buf, sizeof(buf), "system.ini")) + for(s = buf; *s; s += strlen(s) + 1) cnt++; + } + } else { + if (dwFlags & MCI_SYSINFO_OPEN) { + TRACE("MCI_SYSINFO_QUANTITY: # of open MCI drivers of type %u\n", lpParms->wDeviceType); + EnterCriticalSection(&WINMM_IData->cs); + for (wmd = WINMM_IData->lpMciDrvs; wmd; wmd = wmd->lpNext) { + if (wmd->wType == lpParms->wDeviceType) cnt++; + } + LeaveCriticalSection(&WINMM_IData->cs); + } else { + TRACE("MCI_SYSINFO_QUANTITY: # of installed MCI drivers of type %u\n", lpParms->wDeviceType); + FIXME("Don't know how to get # of MCI devices of a given type\n"); + cnt = 1; } - *(DWORD*)lpParms->lpstrReturn = cnt; } + *(DWORD*)lpParms->lpstrReturn = cnt; TRACE("(%ld) => '%ld'\n", lpParms->dwNumber, *(DWORD*)lpParms->lpstrReturn); ret = MCI_INTEGER_RETURNED; break; @@ -1485,14 +1486,31 @@ if (dwFlags & MCI_SYSINFO_OPEN) { FIXME("Don't handle MCI_SYSINFO_NAME|MCI_SYSINFO_OPEN (yet)\n"); ret = MCIERR_UNRECOGNIZED_COMMAND; - } else if (lpParms->dwNumber > MCI_InstalledCount) { - ret = MCIERR_OUTOFRANGE; } else { - DWORD count = lpParms->dwNumber; - LPSTR ptr = MCI_lpInstallNames; - - while (--count > 0) ptr += strlen(ptr) + 1; - ret = MCI_WriteString(lpParms->lpstrReturn, lpParms->dwRetSize, ptr); + DWORD lRet = RegOpenKeyExA( HKEY_LOCAL_MACHINE, HKLM_MCI, 0, KEY_QUERY_VALUE, &hKey ); + if (lRet == ERROR_SUCCESS) { + lRet = RegQueryInfoKeyA( hKey, 0, 0, 0, &cnt, 0, 0, 0, 0, 0, 0, 0); + if (lRet == ERROR_SUCCESS && lpParms->dwNumber <= cnt) { + DWORD bufLen = sizeof(buf); + lRet = RegEnumKeyExA(hKey, lpParms->dwNumber - 1, buf, &bufLen, 0, 0, 0, 0); + if (lRet == ERROR_SUCCESS) s = buf; + } + RegCloseKey( hKey ); + } + if (lRet != ERROR_SUCCESS) { + if (GetPrivateProfileStringA("mci", 0, "", buf, sizeof(buf), "system.ini")) { + for(s = buf; *s; s += strlen(s) + 1, cnt++) { + if (cnt == lpParms->dwNumber - 1) { + lRet = ERROR_SUCCESS; + break; + } + } + } + } + if (lRet == ERROR_SUCCESS) + ret = MCI_WriteString(lpParms->lpstrReturn, lpParms->dwRetSize, s); + else + ret = MCIERR_OUTOFRANGE; } TRACE("(%ld) => '%s'\n", lpParms->dwNumber, lpParms->lpstrReturn); break; @@ -1682,53 +1700,3 @@ return LOWORD(dwRet); } -/************************************************************************** - * MCI_Init [internal] - * - * Initializes the MCI internal variables. - * - */ -BOOL MCI_Init(void) -{ - LPSTR ptr1, ptr2; - HKEY hWineConf; - HKEY hkey; - DWORD err; - DWORD type; - DWORD count = 2048; - - MCI_InstalledCount = 0; - ptr1 = MCI_lpInstallNames = HeapAlloc(GetProcessHeap(), 0, count); - - if (!MCI_lpInstallNames) - return FALSE; - - /* FIXME: should do also some registry diving here ? */ - if (!(err = RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config", &hWineConf)) && - !(err = RegOpenKeyA(hWineConf, "options", &hkey))) { - err = RegQueryValueExA(hkey, "mci", 0, &type, MCI_lpInstallNames, &count); - RegCloseKey(hkey); - - } - if (!err) { - TRACE("Wine => '%s' \n", ptr1); - while ((ptr2 = strchr(ptr1, ':')) != 0) { - *ptr2++ = 0; - TRACE("---> '%s' \n", ptr1); - MCI_InstalledCount++; - ptr1 = ptr2; - } - MCI_InstalledCount++; - TRACE("---> '%s' \n", ptr1); - ptr1 += strlen(ptr1) + 1; - } else { - GetPrivateProfileStringA("mci", NULL, "", MCI_lpInstallNames, count, "SYSTEM.INI"); - while (strlen(ptr1) > 0) { - TRACE("---> '%s' \n", ptr1); - ptr1 += strlen(ptr1) + 1; - MCI_InstalledCount++; - } - } - RegCloseKey(hWineConf); - return TRUE; -} Index: dlls/winmm/winemm.h =================================================================== RCS file: /var/cvs/wine/dlls/winmm/winemm.h,v retrieving revision 1.48 diff -u -r1.48 winemm.h --- dlls/winmm/winemm.h 9 Nov 2003 01:19:58 -0000 1.48 +++ dlls/winmm/winemm.h 24 Nov 2003 16:34:09 -0000 @@ -248,7 +248,6 @@ void MMDRV_InstallMap(unsigned int, MMDRV_MAPFUNC, MMDRV_UNMAPFUNC, MMDRV_MAPFUNC, MMDRV_UNMAPFUNC, LPDRVCALLBACK); -BOOL MCI_Init(void); WINE_MCIDRIVER* MCI_GetDriver(UINT16 uDevID); UINT MCI_GetDriverFromString(LPCSTR str); DWORD MCI_WriteString(LPSTR lpDstStr, DWORD dstSize, LPCSTR lpSrcStr); Index: dlls/winmm/winmm.c =================================================================== RCS file: /var/cvs/wine/dlls/winmm/winmm.c,v retrieving revision 1.24 diff -u -r1.24 winmm.c --- dlls/winmm/winmm.c 9 Nov 2003 01:19:58 -0000 1.24 +++ dlls/winmm/winmm.c 22 Nov 2003 01:42:56 -0000 @@ -148,7 +148,7 @@ if (!WINMM_CreateIData(hInstDLL)) return FALSE; - if (!MCI_Init() || !MMDRV_Init()) { + if (!MMDRV_Init()) { WINMM_DeleteIData(); return FALSE; } -- Dimi.