Eric, I think these values (*.drv) sit under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\MCI and not under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\MCI32 as you suggested. By making the values dynamic (no longer read them at init time), code gets simplified, user is happier. 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/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 22 Nov 2003 02:48:07 -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 ) { @@ -447,9 +447,15 @@ static BOOL MCI_OpenMciDriver(LPWINE_MCIDRIVER wmd, LPCSTR drvTyp, LPARAM lp) { char libName[128]; + HKEY hKey; + DWORD libNameLen = sizeof(libName), lRet; - if (!DRIVER_GetLibName(drvTyp, "mci", libName, sizeof(libName))) - return FALSE; + lRet = RegOpenKeyExA(HKEY_LOCAL_MACHINE, HKLM_MCI, 0, KEY_QUERY_VALUE, &hKey); + if (lRet == ERROR_SUCCESS) { + lRet = RegQueryValueExA(hKey, drvTyp, 0, 0, libName, &libNameLen); + RegCloseKey( hKey ); + } + if (lRet != ERROR_SUCCESS) return FALSE; wmd->bIs32 = 0xFFFF; /* First load driver */ @@ -1423,6 +1429,8 @@ { DWORD ret = MCIERR_INVALID_DEVICE_ID; LPWINE_MCIDRIVER wmd; + DWORD cnt = 0; + HKEY hKey; if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK; @@ -1431,41 +1439,37 @@ 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 ); } } - *(DWORD*)lpParms->lpstrReturn = 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; TRACE("(%ld) => '%ld'\n", lpParms->dwNumber, *(DWORD*)lpParms->lpstrReturn); ret = MCI_INTEGER_RETURNED; break; @@ -1485,14 +1489,20 @@ 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); + ret = MCIERR_DRIVER_INTERNAL; + if (RegOpenKeyExA( HKEY_LOCAL_MACHINE, HKLM_MCI, + 0, KEY_QUERY_VALUE, &hKey ) == ERROR_SUCCESS) { + CHAR achKey[256]; + DWORD cbName = sizeof(achKey), lRet; + + lRet = RegEnumKeyExA(hKey, lpParms->dwNumber - 1, achKey, &cbName, 0, 0, 0, 0); + RegCloseKey( hKey ); + if (lRet == ERROR_SUCCESS) + ret = MCI_WriteString(lpParms->lpstrReturn, lpParms->dwRetSize, achKey); + else if (lRet == ERROR_NO_MORE_ITEMS) + ret = MCIERR_OUTOFRANGE; + } } TRACE("(%ld) => '%s'\n", lpParms->dwNumber, lpParms->lpstrReturn); break; @@ -1682,53 +1692,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 22 Nov 2003 02:48:18 -0000 @@ -228,7 +228,6 @@ typedef WINMM_MapType (*MMDRV_UNMAPFUNC)(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2, MMRESULT ret); LPWINE_DRIVER DRIVER_FindFromHDrvr(HDRVR hDrvr); -BOOL DRIVER_GetLibName(LPCSTR keyName, LPCSTR sectName, LPSTR buf, int sz); LPWINE_DRIVER DRIVER_TryOpenDriver32(LPCSTR fn, LPARAM lParam2); void DRIVER_UnloadAll(void); @@ -248,7 +247,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.