Index: dll/cpl/mmsys/sounds.c =================================================================== --- dll/cpl/mmsys/sounds.c (revision 71918) +++ dll/cpl/mmsys/sounds.c (working copy) @@ -5,6 +5,7 @@ * PROGRAMMER: Thomas Weidenmueller * Johannes Anderwald * Dmitry Chapyshev + * Victor Martinez Calvo */ #include "mmsys.h" @@ -11,7 +12,7 @@ #include #include - +#include struct __APP_MAP__; typedef struct __LABEL_MAP__ @@ -291,6 +292,8 @@ HKEY hSubKey; TCHAR szValue[MAX_PATH]; DWORD dwValue, dwResult; + LRESULT lResult; + PSOUND_SCHEME_CONTEXT pScheme; if (RegOpenKeyEx(hKey, szSubKey, @@ -309,27 +312,32 @@ (LPBYTE)szValue, &dwValue); RegCloseKey(hSubKey); - if (dwResult == ERROR_SUCCESS) - { - LRESULT lResult = SendDlgItemMessage(hwndDlg, IDC_SOUND_SCHEME, CB_ADDSTRING, (WPARAM)0, (LPARAM)szValue); - if (lResult != CB_ERR) - { - PSOUND_SCHEME_CONTEXT pScheme = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(SOUND_SCHEME_CONTEXT)); - if (pScheme != NULL) - { - _tcscpy(pScheme->szDesc, szValue); - _tcscpy(pScheme->szName, szSubKey); - } - SendDlgItemMessage(hwndDlg, IDC_SOUND_SCHEME, CB_SETITEMDATA, (WPARAM)lResult, (LPARAM)pScheme); - if (SetDefault) - { - SendDlgItemMessage(hwndDlg, IDC_SOUND_SCHEME, CB_SETCURSEL, (WPARAM)lResult, (LPARAM)0); - } - } - return TRUE; - } - return FALSE; + if (dwResult != ERROR_SUCCESS) + return FALSE; + + /* Try to add the new profile to the combobox */ + lResult = SendDlgItemMessage(hwndDlg, IDC_SOUND_SCHEME, CB_ADDSTRING, (WPARAM)0, (LPARAM)szValue); + if (lResult == CB_ERR) + return FALSE; + + pScheme = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(SOUND_SCHEME_CONTEXT)); + if (pScheme == NULL) + return FALSE; + + StringCchCopy(pScheme->szDesc, MAX_PATH, szValue); + StringCchCopy(pScheme->szName, MAX_PATH, szSubKey); + + /* Try to associate the value with the item in the combobox*/ + lResult = SendDlgItemMessage(hwndDlg, IDC_SOUND_SCHEME, CB_SETITEMDATA, (WPARAM)lResult, (LPARAM)pScheme); + if (lResult == CB_ERR) + return FALSE; + + /* Optionally: Select the profile */ + if (SetDefault) + SendDlgItemMessage(hwndDlg, IDC_SOUND_SCHEME, CB_SETCURSEL, (WPARAM)lResult, (LPARAM)0); + + return TRUE; }