mirror of
https://github.com/reactos/reactos.git
synced 2025-04-04 20:50:41 +00:00
[MMSYS] Multimedia Control Panel diverse fixes (#4572)
- Use Unicode (WCHAR) instead of TCHAR - Code formatting - Use string safe functions - Close handles after calling `CreateProcess` - Save sound path as `REG_EXPAND_SZ` only if the path contains '%' character, like Windows does - Fix `wcsdup` leaks Reviewed-by: Mark Jansen <mark.jansen@reactos.org> Reviewed-by: Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org> Reviewed-by: Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com> Reviewed-by: Stanislav Motylkov <x86corez@gmail.com>
This commit is contained in:
parent
67f7971fa2
commit
781c247bd3
7 changed files with 559 additions and 523 deletions
|
@ -26,15 +26,15 @@ VOID
|
|||
InitAudioDlg(HWND hwnd, PGLOBAL_DATA pGlobalData)
|
||||
{
|
||||
WAVEOUTCAPSW waveOutputPaps;
|
||||
WAVEINCAPS waveInputPaps;
|
||||
MIDIOUTCAPS midiOutCaps;
|
||||
TCHAR szNoDevices[256];
|
||||
WAVEINCAPSW waveInputPaps;
|
||||
MIDIOUTCAPSW midiOutCaps;
|
||||
WCHAR szNoDevices[256];
|
||||
UINT DevsNum;
|
||||
UINT uIndex;
|
||||
HWND hCB;
|
||||
LRESULT Res;
|
||||
|
||||
LoadString(hApplet, IDS_NO_DEVICES, szNoDevices, _countof(szNoDevices));
|
||||
LoadStringW(hApplet, IDS_NO_DEVICES, szNoDevices, _countof(szNoDevices));
|
||||
|
||||
// Init sound playback devices list
|
||||
hCB = GetDlgItem(hwnd, IDC_DEVICE_PLAY_LIST);
|
||||
|
@ -42,8 +42,8 @@ InitAudioDlg(HWND hwnd, PGLOBAL_DATA pGlobalData)
|
|||
DevsNum = waveOutGetNumDevs();
|
||||
if (DevsNum < 1)
|
||||
{
|
||||
Res = SendMessage(hCB, CB_ADDSTRING, 0, (LPARAM)szNoDevices);
|
||||
SendMessage(hCB, CB_SETCURSEL, (WPARAM) Res, 0);
|
||||
Res = SendMessageW(hCB, CB_ADDSTRING, 0, (LPARAM)szNoDevices);
|
||||
SendMessageW(hCB, CB_SETCURSEL, (WPARAM)Res, 0);
|
||||
pGlobalData->bNoAudioOut = TRUE;
|
||||
}
|
||||
else
|
||||
|
@ -56,7 +56,7 @@ InitAudioDlg(HWND hwnd, PGLOBAL_DATA pGlobalData)
|
|||
if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Multimedia\\Sound Mapper", 0, KEY_READ, &hKey) == ERROR_SUCCESS)
|
||||
{
|
||||
RegQueryValueExW(hKey, L"Playback", NULL, NULL, (LPBYTE)DefaultDevice, &dwSize);
|
||||
DefaultDevice[MAX_PATH-1] = L'\0';
|
||||
DefaultDevice[_countof(DefaultDevice) - 1] = UNICODE_NULL;
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
|
||||
|
@ -65,16 +65,16 @@ InitAudioDlg(HWND hwnd, PGLOBAL_DATA pGlobalData)
|
|||
if (waveOutGetDevCapsW(uIndex, &waveOutputPaps, sizeof(waveOutputPaps)))
|
||||
continue;
|
||||
|
||||
Res = SendMessageW(hCB, CB_ADDSTRING, 0, (LPARAM) waveOutputPaps.szPname);
|
||||
Res = SendMessageW(hCB, CB_ADDSTRING, 0, (LPARAM)waveOutputPaps.szPname);
|
||||
|
||||
if (CB_ERR != Res)
|
||||
{
|
||||
SendMessage(hCB, CB_SETITEMDATA, Res, (LPARAM) uIndex);
|
||||
if (!wcsicmp(waveOutputPaps.szPname, DefaultDevice))
|
||||
SendMessageW(hCB, CB_SETITEMDATA, Res, (LPARAM)uIndex);
|
||||
if (!_wcsicmp(waveOutputPaps.szPname, DefaultDevice))
|
||||
DefaultIndex = Res;
|
||||
}
|
||||
}
|
||||
SendMessage(hCB, CB_SETCURSEL, (WPARAM) DefaultIndex, 0);
|
||||
SendMessageW(hCB, CB_SETCURSEL, (WPARAM)DefaultIndex, 0);
|
||||
}
|
||||
|
||||
// Init sound recording devices list
|
||||
|
@ -83,8 +83,8 @@ InitAudioDlg(HWND hwnd, PGLOBAL_DATA pGlobalData)
|
|||
DevsNum = waveInGetNumDevs();
|
||||
if (DevsNum < 1)
|
||||
{
|
||||
Res = SendMessage(hCB, CB_ADDSTRING, 0, (LPARAM)szNoDevices);
|
||||
SendMessage(hCB, CB_SETCURSEL, (WPARAM) Res, 0);
|
||||
Res = SendMessageW(hCB, CB_ADDSTRING, 0, (LPARAM)szNoDevices);
|
||||
SendMessageW(hCB, CB_SETCURSEL, (WPARAM)Res, 0);
|
||||
pGlobalData->bNoAudioIn = TRUE;
|
||||
}
|
||||
else
|
||||
|
@ -97,26 +97,26 @@ InitAudioDlg(HWND hwnd, PGLOBAL_DATA pGlobalData)
|
|||
if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Multimedia\\Sound Mapper", 0, KEY_READ, &hKey) == ERROR_SUCCESS)
|
||||
{
|
||||
RegQueryValueExW(hKey, L"Record", NULL, NULL, (LPBYTE)DefaultDevice, &dwSize);
|
||||
DefaultDevice[MAX_PATH-1] = L'\0';
|
||||
DefaultDevice[_countof(DefaultDevice) - 1] = UNICODE_NULL;
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
|
||||
|
||||
for (uIndex = 0; uIndex < DevsNum; uIndex++)
|
||||
{
|
||||
if (waveInGetDevCaps(uIndex, &waveInputPaps, sizeof(waveInputPaps)))
|
||||
if (waveInGetDevCapsW(uIndex, &waveInputPaps, sizeof(waveInputPaps)))
|
||||
continue;
|
||||
|
||||
Res = SendMessage(hCB, CB_ADDSTRING, 0, (LPARAM) waveInputPaps.szPname);
|
||||
Res = SendMessageW(hCB, CB_ADDSTRING, 0, (LPARAM)waveInputPaps.szPname);
|
||||
|
||||
if (CB_ERR != Res)
|
||||
{
|
||||
SendMessage(hCB, CB_SETITEMDATA, Res, (LPARAM) uIndex);
|
||||
if (!wcsicmp(waveInputPaps.szPname, DefaultDevice))
|
||||
SendMessageW(hCB, CB_SETITEMDATA, Res, (LPARAM)uIndex);
|
||||
if (!_wcsicmp(waveInputPaps.szPname, DefaultDevice))
|
||||
DefaultIndex = Res;
|
||||
}
|
||||
}
|
||||
SendMessage(hCB, CB_SETCURSEL, (WPARAM) DefaultIndex, 0);
|
||||
SendMessageW(hCB, CB_SETCURSEL, (WPARAM)DefaultIndex, 0);
|
||||
}
|
||||
|
||||
// Init MIDI devices list
|
||||
|
@ -125,8 +125,8 @@ InitAudioDlg(HWND hwnd, PGLOBAL_DATA pGlobalData)
|
|||
DevsNum = midiOutGetNumDevs();
|
||||
if (DevsNum < 1)
|
||||
{
|
||||
Res = SendMessage(hCB, CB_ADDSTRING, 0, (LPARAM)szNoDevices);
|
||||
SendMessage(hCB, CB_SETCURSEL, (WPARAM) Res, 0);
|
||||
Res = SendMessageW(hCB, CB_ADDSTRING, 0, (LPARAM)szNoDevices);
|
||||
SendMessageW(hCB, CB_SETCURSEL, (WPARAM)Res, 0);
|
||||
pGlobalData->bNoMIDIOut = TRUE;
|
||||
}
|
||||
else
|
||||
|
@ -139,25 +139,25 @@ InitAudioDlg(HWND hwnd, PGLOBAL_DATA pGlobalData)
|
|||
if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Multimedia\\MIDIMap", 0, KEY_READ, &hKey) == ERROR_SUCCESS)
|
||||
{
|
||||
RegQueryValueExW(hKey, L"szPname", NULL, NULL, (LPBYTE)DefaultDevice, &dwSize);
|
||||
DefaultDevice[MAX_PATH-1] = L'\0';
|
||||
DefaultDevice[_countof(DefaultDevice) - 1] = UNICODE_NULL;
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
|
||||
for (uIndex = 0; uIndex < DevsNum; uIndex++)
|
||||
{
|
||||
if (midiOutGetDevCaps(uIndex, &midiOutCaps, sizeof(midiOutCaps)))
|
||||
if (midiOutGetDevCapsW(uIndex, &midiOutCaps, sizeof(midiOutCaps)))
|
||||
continue;
|
||||
|
||||
Res = SendMessage(hCB, CB_ADDSTRING, 0, (LPARAM) midiOutCaps.szPname);
|
||||
Res = SendMessageW(hCB, CB_ADDSTRING, 0, (LPARAM)midiOutCaps.szPname);
|
||||
|
||||
if (CB_ERR != Res)
|
||||
{
|
||||
SendMessage(hCB, CB_SETITEMDATA, Res, (LPARAM) uIndex);
|
||||
if (!wcsicmp(midiOutCaps.szPname, DefaultDevice))
|
||||
SendMessageW(hCB, CB_SETITEMDATA, Res, (LPARAM)uIndex);
|
||||
if (!_wcsicmp(midiOutCaps.szPname, DefaultDevice))
|
||||
DefaultIndex = Res;
|
||||
}
|
||||
}
|
||||
SendMessage(hCB, CB_SETCURSEL, (WPARAM) DefaultIndex, 0);
|
||||
SendMessageW(hCB, CB_SETCURSEL, (WPARAM)DefaultIndex, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -165,7 +165,7 @@ VOID
|
|||
UpdateRegistryString(HWND hwnd, INT ctrl, LPWSTR key, LPWSTR value)
|
||||
{
|
||||
HWND hwndCombo = GetDlgItem(hwnd, ctrl);
|
||||
INT CurSel = SendMessage(hwndCombo, CB_GETCURSEL, 0, 0);
|
||||
INT CurSel = SendMessageW(hwndCombo, CB_GETCURSEL, 0, 0);
|
||||
UINT TextLen;
|
||||
WCHAR SelectedDevice[MAX_PATH] = {0};
|
||||
HKEY hKey;
|
||||
|
@ -183,7 +183,7 @@ UpdateRegistryString(HWND hwnd, INT ctrl, LPWSTR key, LPWSTR value)
|
|||
if (RegCreateKeyExW(HKEY_CURRENT_USER, key, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, NULL) != ERROR_SUCCESS)
|
||||
return;
|
||||
|
||||
RegSetValueExW(hKey, value, 0, REG_SZ, (BYTE *)SelectedDevice, (wcslen(SelectedDevice) + 1) * sizeof(WCHAR));
|
||||
RegSetValueExW(hKey, value, 0, REG_SZ, (BYTE*)SelectedDevice, (wcslen(SelectedDevice) + 1) * sizeof(WCHAR));
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
|
||||
|
@ -221,12 +221,12 @@ GetDevNum(HWND hControl, DWORD Id)
|
|||
int iCurSel;
|
||||
UINT DevNum;
|
||||
|
||||
iCurSel = SendMessage(hControl, CB_GETCURSEL, 0, 0);
|
||||
iCurSel = SendMessageW(hControl, CB_GETCURSEL, 0, 0);
|
||||
|
||||
if (iCurSel == CB_ERR)
|
||||
return 0;
|
||||
|
||||
DevNum = (UINT) SendMessage(hControl, CB_GETITEMDATA, iCurSel, 0);
|
||||
DevNum = (UINT)SendMessageW(hControl, CB_GETITEMDATA, iCurSel, 0);
|
||||
if (DevNum == (UINT) CB_ERR)
|
||||
return 0;
|
||||
|
||||
|
@ -245,16 +245,16 @@ AudioDlgProc(HWND hwndDlg,
|
|||
{
|
||||
PGLOBAL_DATA pGlobalData;
|
||||
|
||||
pGlobalData = (PGLOBAL_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
|
||||
pGlobalData = (PGLOBAL_DATA)GetWindowLongPtrW(hwndDlg, DWLP_USER);
|
||||
|
||||
switch(uMsg)
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
UINT NumWavOut = waveOutGetNumDevs();
|
||||
|
||||
pGlobalData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(GLOBAL_DATA));
|
||||
SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData);
|
||||
SetWindowLongPtrW(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData);
|
||||
|
||||
if (!pGlobalData)
|
||||
break;
|
||||
|
@ -300,26 +300,30 @@ AudioDlgProc(HWND hwndDlg,
|
|||
|
||||
case WM_COMMAND:
|
||||
{
|
||||
STARTUPINFO si;
|
||||
STARTUPINFOW si;
|
||||
PROCESS_INFORMATION pi;
|
||||
WCHAR szPath[MAX_PATH];
|
||||
|
||||
if (!pGlobalData)
|
||||
break;
|
||||
|
||||
switch(LOWORD(wParam))
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDC_VOLUME1_BTN:
|
||||
{
|
||||
wsprintf(szPath, L"sndvol32.exe -d %d",
|
||||
GetDevNum(GetDlgItem(hwndDlg, IDC_DEVICE_PLAY_LIST), MIXER_OBJECTF_WAVEOUT));
|
||||
StringCchPrintfW(szPath, _countof(szPath), L"sndvol32.exe -d %d",
|
||||
GetDevNum(GetDlgItem(hwndDlg, IDC_DEVICE_PLAY_LIST), MIXER_OBJECTF_WAVEOUT));
|
||||
|
||||
ZeroMemory(&si, sizeof(si));
|
||||
si.cb = sizeof(si);
|
||||
si.dwFlags = STARTF_USESHOWWINDOW;
|
||||
si.wShowWindow = SW_SHOW;
|
||||
|
||||
CreateProcess(NULL, szPath, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
|
||||
if (CreateProcessW(NULL, szPath, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
|
||||
{
|
||||
CloseHandle(pi.hProcess);
|
||||
CloseHandle(pi.hThread);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -331,15 +335,19 @@ AudioDlgProc(HWND hwndDlg,
|
|||
|
||||
case IDC_VOLUME2_BTN:
|
||||
{
|
||||
wsprintf(szPath, L"sndvol32.exe -r -d %d",
|
||||
GetDevNum(GetDlgItem(hwndDlg, IDC_DEVICE_REC_LIST), MIXER_OBJECTF_WAVEIN));
|
||||
StringCchPrintfW(szPath, _countof(szPath), L"sndvol32.exe -r -d %d",
|
||||
GetDevNum(GetDlgItem(hwndDlg, IDC_DEVICE_REC_LIST), MIXER_OBJECTF_WAVEIN));
|
||||
|
||||
ZeroMemory(&si, sizeof(si));
|
||||
si.cb = sizeof(si);
|
||||
si.dwFlags = STARTF_USESHOWWINDOW;
|
||||
si.wShowWindow = SW_SHOW;
|
||||
|
||||
CreateProcess(NULL, szPath, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
|
||||
if (CreateProcessW(NULL, szPath, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
|
||||
{
|
||||
CloseHandle(pi.hProcess);
|
||||
CloseHandle(pi.hThread);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -351,15 +359,19 @@ AudioDlgProc(HWND hwndDlg,
|
|||
|
||||
case IDC_VOLUME3_BTN:
|
||||
{
|
||||
wsprintf(szPath, L"sndvol32.exe -d %d",
|
||||
GetDevNum(GetDlgItem(hwndDlg, IDC_DEVICE_MIDI_LIST), MIXER_OBJECTF_MIDIOUT));
|
||||
StringCchPrintfW(szPath, _countof(szPath), L"sndvol32.exe -d %d",
|
||||
GetDevNum(GetDlgItem(hwndDlg, IDC_DEVICE_MIDI_LIST), MIXER_OBJECTF_MIDIOUT));
|
||||
|
||||
ZeroMemory(&si, sizeof(si));
|
||||
si.cb = sizeof(si);
|
||||
si.dwFlags = STARTF_USESHOWWINDOW;
|
||||
si.wShowWindow = SW_SHOW;
|
||||
|
||||
CreateProcess(NULL, szPath, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
|
||||
if (CreateProcessW(NULL, szPath, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
|
||||
{
|
||||
CloseHandle(pi.hProcess);
|
||||
CloseHandle(pi.hThread);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -33,14 +33,14 @@ typedef struct
|
|||
LPWSTR DefaultName;
|
||||
UINT LocalizedResId;
|
||||
LPWSTR FileName;
|
||||
}EVENT_LABEL_ITEM;
|
||||
} EVENT_LABEL_ITEM;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
LPWSTR LabelName;
|
||||
LPWSTR DefaultName;
|
||||
UINT IconId;
|
||||
}SYSTEM_SCHEME_ITEM;
|
||||
} SYSTEM_SCHEME_ITEM;
|
||||
|
||||
static EVENT_LABEL_ITEM EventLabels[] =
|
||||
{
|
||||
|
@ -89,12 +89,12 @@ DeviceCreateHardwarePageEx(HWND hWndParent,
|
|||
UINT uNumberOfGuids,
|
||||
HWPAGE_DISPLAYMODE DisplayMode);
|
||||
|
||||
typedef BOOL (WINAPI *UpdateDriverForPlugAndPlayDevicesProto)(IN OPTIONAL HWND hwndParent,
|
||||
IN LPCTSTR HardwareId,
|
||||
IN LPCTSTR FullInfPath,
|
||||
IN DWORD InstallFlags,
|
||||
OUT OPTIONAL PBOOL bRebootRequired
|
||||
);
|
||||
typedef BOOL (WINAPI *UpdateDriverForPlugAndPlayDevicesProto)(
|
||||
_In_opt_ HWND hwndParent,
|
||||
_In_ LPCWSTR HardwareId,
|
||||
_In_ LPCWSTR FullInfPath,
|
||||
_In_ DWORD InstallFlags,
|
||||
_Out_opt_ PBOOL bRebootRequired);
|
||||
|
||||
#define UPDATEDRIVERFORPLUGANDPLAYDEVICES "UpdateDriverForPlugAndPlayDevicesW"
|
||||
#define NUM_APPLETS (1)
|
||||
|
@ -105,7 +105,7 @@ HINSTANCE hApplet = 0;
|
|||
/* Applets */
|
||||
const APPLET Applets[NUM_APPLETS] =
|
||||
{
|
||||
{IDI_CPLICON, IDS_CPLNAME, IDS_CPLDESCRIPTION, MmSysApplet},
|
||||
{IDI_CPLICON, IDS_CPLNAME, IDS_CPLDESCRIPTION, MmSysApplet},
|
||||
};
|
||||
|
||||
|
||||
|
@ -208,16 +208,16 @@ InstallSystemSoundLabels(HKEY hKey)
|
|||
|
||||
do
|
||||
{
|
||||
if (RegCreateKeyExW(hKey, EventLabels[i].LabelName, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hSubKey, NULL) == ERROR_SUCCESS)
|
||||
if (RegCreateKeyExW(hKey, EventLabels[i].LabelName, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hSubKey, NULL) == ERROR_SUCCESS)
|
||||
{
|
||||
RegSetValueExW(hSubKey, NULL, 0, REG_SZ, (LPBYTE)EventLabels[i].DefaultName, (wcslen(EventLabels[i].DefaultName)+1) * sizeof(WCHAR));
|
||||
swprintf(Buffer, L"@mmsys.cpl,-%u", EventLabels[i].LocalizedResId);
|
||||
RegSetValueExW(hSubKey, L"DispFileName", 0, REG_SZ, (LPBYTE)Buffer, (wcslen(Buffer)+1) * sizeof(WCHAR));
|
||||
RegSetValueExW(hSubKey, NULL, 0, REG_SZ, (LPBYTE)EventLabels[i].DefaultName, (wcslen(EventLabels[i].DefaultName) + 1) * sizeof(WCHAR));
|
||||
StringCchPrintfW(Buffer, _countof(Buffer), L"@mmsys.cpl,-%u", EventLabels[i].LocalizedResId);
|
||||
RegSetValueExW(hSubKey, L"DispFileName", 0, REG_SZ, (LPBYTE)Buffer, (wcslen(Buffer) + 1) * sizeof(WCHAR));
|
||||
|
||||
RegCloseKey(hSubKey);
|
||||
}
|
||||
i++;
|
||||
}while(EventLabels[i].LabelName);
|
||||
} while (EventLabels[i].LabelName);
|
||||
}
|
||||
|
||||
VOID
|
||||
|
@ -228,13 +228,13 @@ InstallSystemSoundSchemeNames(HKEY hKey)
|
|||
|
||||
do
|
||||
{
|
||||
if (RegCreateKeyExW(hKey, SystemSchemes[i].LabelName, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hSubKey, NULL) == ERROR_SUCCESS)
|
||||
if (RegCreateKeyExW(hKey, SystemSchemes[i].LabelName, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hSubKey, NULL) == ERROR_SUCCESS)
|
||||
{
|
||||
RegSetValueExW(hSubKey, NULL, 0, REG_SZ, (LPBYTE)SystemSchemes[i].DefaultName, (wcslen(SystemSchemes[i].DefaultName)+1) * sizeof(WCHAR));
|
||||
RegSetValueExW(hSubKey, NULL, 0, REG_SZ, (LPBYTE)SystemSchemes[i].DefaultName, (wcslen(SystemSchemes[i].DefaultName) + 1) * sizeof(WCHAR));
|
||||
RegCloseKey(hSubKey);
|
||||
}
|
||||
i++;
|
||||
}while(SystemSchemes[i].LabelName);
|
||||
} while (SystemSchemes[i].LabelName);
|
||||
}
|
||||
|
||||
VOID
|
||||
|
@ -247,39 +247,39 @@ InstallDefaultSystemSoundScheme(HKEY hRootKey)
|
|||
if (RegCreateKeyExW(hRootKey, L".Default", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, NULL) != ERROR_SUCCESS)
|
||||
return;
|
||||
|
||||
RegSetValueExW(hKey, NULL, 0, REG_SZ, (LPBYTE)SystemSchemes[0].DefaultName, (wcslen(SystemSchemes[0].DefaultName)+1) * sizeof(WCHAR));
|
||||
swprintf(Path, L"@mmsys.cpl,-%u", SystemSchemes[0].IconId);
|
||||
RegSetValueExW(hKey, L"DispFileName", 0, REG_SZ, (LPBYTE)Path, (wcslen(Path)+1) * sizeof(WCHAR));
|
||||
RegSetValueExW(hKey, NULL, 0, REG_SZ, (LPBYTE)SystemSchemes[0].DefaultName, (wcslen(SystemSchemes[0].DefaultName) + 1) * sizeof(WCHAR));
|
||||
StringCchPrintfW(Path, _countof(Path), L"@mmsys.cpl,-%u", SystemSchemes[0].IconId);
|
||||
RegSetValueExW(hKey, L"DispFileName", 0, REG_SZ, (LPBYTE)Path, (wcslen(Path) + 1) * sizeof(WCHAR));
|
||||
|
||||
do
|
||||
{
|
||||
if (RegCreateKeyExW(hKey, EventLabels[i].LabelName, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hSubKey, NULL) == ERROR_SUCCESS)
|
||||
if (RegCreateKeyExW(hKey, EventLabels[i].LabelName, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hSubKey, NULL) == ERROR_SUCCESS)
|
||||
{
|
||||
HKEY hScheme;
|
||||
|
||||
swprintf(Path, L"%%SystemRoot%%\\media\\%s", EventLabels[i].FileName);
|
||||
if (RegCreateKeyExW(hSubKey, L".Current", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hScheme, NULL) == ERROR_SUCCESS)
|
||||
StringCchPrintfW(Path, _countof(Path), L"%%SystemRoot%%\\media\\%s", EventLabels[i].FileName);
|
||||
if (RegCreateKeyExW(hSubKey, L".Current", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hScheme, NULL) == ERROR_SUCCESS)
|
||||
{
|
||||
RegSetValueExW(hScheme, NULL, 0, REG_EXPAND_SZ, (LPBYTE)Path, (wcslen(Path)+1) * sizeof(WCHAR));
|
||||
RegSetValueExW(hScheme, NULL, 0, REG_EXPAND_SZ, (LPBYTE)Path, (wcslen(Path) + 1) * sizeof(WCHAR));
|
||||
RegCloseKey(hScheme);
|
||||
}
|
||||
|
||||
if (RegCreateKeyExW(hSubKey, L".Default", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hScheme, NULL) == ERROR_SUCCESS)
|
||||
if (RegCreateKeyExW(hSubKey, L".Default", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hScheme, NULL) == ERROR_SUCCESS)
|
||||
{
|
||||
RegSetValueExW(hScheme, NULL, 0, REG_EXPAND_SZ, (LPBYTE)Path, (wcslen(Path)+1) * sizeof(WCHAR));
|
||||
RegSetValueExW(hScheme, NULL, 0, REG_EXPAND_SZ, (LPBYTE)Path, (wcslen(Path) + 1) * sizeof(WCHAR));
|
||||
RegCloseKey(hScheme);
|
||||
}
|
||||
RegCloseKey(hSubKey);
|
||||
}
|
||||
i++;
|
||||
}while(EventLabels[i].LabelName);
|
||||
} while (EventLabels[i].LabelName);
|
||||
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
InstallSystemSoundScheme()
|
||||
InstallSystemSoundScheme(VOID)
|
||||
{
|
||||
HKEY hKey, hSubKey;
|
||||
DWORD dwDisposition;
|
||||
|
@ -310,7 +310,7 @@ InstallSystemSoundScheme()
|
|||
if (dwDisposition & REG_CREATED_NEW_KEY)
|
||||
{
|
||||
// FIXME
|
||||
RegSetValueExW(hSubKey, NULL, 0, REG_SZ, (LPBYTE)L".Default", (wcslen(L".Default")+1) * sizeof(WCHAR));
|
||||
RegSetValueExW(hSubKey, NULL, 0, REG_SZ, (LPBYTE)L".Default", sizeof(L".Default"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -328,7 +328,7 @@ IsSoftwareBusPnpEnumeratorInstalled()
|
|||
GUID SWBusGuid = {STATIC_BUSID_SoftwareDeviceEnumerator};
|
||||
PSP_DEVICE_INTERFACE_DETAIL_DATA_W DeviceInterfaceDetailData;
|
||||
|
||||
hDevInfo = SetupDiGetClassDevsW(&SWBusGuid, NULL, NULL, DIGCF_DEVICEINTERFACE| DIGCF_PRESENT);
|
||||
hDevInfo = SetupDiGetClassDevsW(&SWBusGuid, NULL, NULL, DIGCF_DEVICEINTERFACE | DIGCF_PRESENT);
|
||||
if (!hDevInfo)
|
||||
{
|
||||
// failed
|
||||
|
@ -343,7 +343,7 @@ IsSoftwareBusPnpEnumeratorInstalled()
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
DeviceInterfaceDetailData = (PSP_DEVICE_INTERFACE_DETAIL_DATA_W)HeapAlloc(GetProcessHeap(), 0, MAX_PATH * sizeof(WCHAR) + sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_W));
|
||||
DeviceInterfaceDetailData = (PSP_DEVICE_INTERFACE_DETAIL_DATA_W)HeapAlloc(GetProcessHeap(), 0, (MAX_PATH * sizeof(WCHAR)) + sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_W));
|
||||
if (!DeviceInterfaceDetailData)
|
||||
{
|
||||
// failed
|
||||
|
@ -352,7 +352,7 @@ IsSoftwareBusPnpEnumeratorInstalled()
|
|||
}
|
||||
|
||||
DeviceInterfaceDetailData->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_W);
|
||||
if (!SetupDiGetDeviceInterfaceDetailW(hDevInfo, &DeviceInterfaceData, DeviceInterfaceDetailData,MAX_PATH * sizeof(WCHAR) + sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_W), NULL, NULL))
|
||||
if (!SetupDiGetDeviceInterfaceDetailW(hDevInfo, &DeviceInterfaceData, DeviceInterfaceDetailData, (MAX_PATH * sizeof(WCHAR)) + sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_W), NULL, NULL))
|
||||
{
|
||||
// failed
|
||||
HeapFree(GetProcessHeap(), 0, DeviceInterfaceDetailData);
|
||||
|
@ -370,32 +370,32 @@ InstallSoftwareBusPnpEnumerator(LPWSTR InfPath, LPCWSTR HardwareIdList)
|
|||
HDEVINFO DeviceInfoSet = INVALID_HANDLE_VALUE;
|
||||
SP_DEVINFO_DATA DeviceInfoData;
|
||||
GUID ClassGUID;
|
||||
TCHAR ClassName[50];
|
||||
WCHAR ClassName[50];
|
||||
int Result = 0;
|
||||
HMODULE hModule = NULL;
|
||||
UpdateDriverForPlugAndPlayDevicesProto UpdateProc;
|
||||
BOOL reboot = FALSE;
|
||||
DWORD flags = 0;
|
||||
|
||||
if (!SetupDiGetINFClass(InfPath,&ClassGUID,ClassName,sizeof(ClassName)/sizeof(ClassName[0]),0))
|
||||
if (!SetupDiGetINFClassW(InfPath, &ClassGUID, ClassName, _countof(ClassName), NULL))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
DeviceInfoSet = SetupDiCreateDeviceInfoList(&ClassGUID,0);
|
||||
if(DeviceInfoSet == INVALID_HANDLE_VALUE)
|
||||
DeviceInfoSet = SetupDiCreateDeviceInfoList(&ClassGUID, NULL);
|
||||
if (DeviceInfoSet == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
|
||||
if (!SetupDiCreateDeviceInfo(DeviceInfoSet, ClassName, &ClassGUID, NULL, 0, DICD_GENERATE_ID, &DeviceInfoData))
|
||||
if (!SetupDiCreateDeviceInfoW(DeviceInfoSet, ClassName, &ClassGUID, NULL, NULL, DICD_GENERATE_ID, &DeviceInfoData))
|
||||
{
|
||||
SetupDiDestroyDeviceInfoList(DeviceInfoSet);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(!SetupDiSetDeviceRegistryProperty(DeviceInfoSet, &DeviceInfoData, SPDRP_HARDWAREID, (LPBYTE)HardwareIdList, (lstrlen(HardwareIdList)+1+1)*sizeof(TCHAR)))
|
||||
if (!SetupDiSetDeviceRegistryPropertyW(DeviceInfoSet, &DeviceInfoData, SPDRP_HARDWAREID, (LPBYTE)HardwareIdList, (wcslen(HardwareIdList) + 1 + 1) * sizeof(WCHAR)))
|
||||
{
|
||||
SetupDiDestroyDeviceInfoList(DeviceInfoSet);
|
||||
return -1;
|
||||
|
@ -407,27 +407,29 @@ InstallSoftwareBusPnpEnumerator(LPWSTR InfPath, LPCWSTR HardwareIdList)
|
|||
return -1;
|
||||
}
|
||||
|
||||
if(GetFileAttributes(InfPath)==(DWORD)(-1)) {
|
||||
if (GetFileAttributesW(InfPath) == INVALID_FILE_ATTRIBUTES)
|
||||
{
|
||||
SetupDiDestroyDeviceInfoList(DeviceInfoSet);
|
||||
return -1;
|
||||
}
|
||||
|
||||
flags |= INSTALLFLAG_FORCE;
|
||||
hModule = LoadLibraryW(L"newdev.dll");
|
||||
if(!hModule) {
|
||||
if (!hModule)
|
||||
{
|
||||
SetupDiDestroyDeviceInfoList(DeviceInfoSet);
|
||||
return -1;
|
||||
}
|
||||
|
||||
UpdateProc = (UpdateDriverForPlugAndPlayDevicesProto)GetProcAddress(hModule,UPDATEDRIVERFORPLUGANDPLAYDEVICES);
|
||||
if(!UpdateProc)
|
||||
UpdateProc = (UpdateDriverForPlugAndPlayDevicesProto)GetProcAddress(hModule, UPDATEDRIVERFORPLUGANDPLAYDEVICES);
|
||||
if (!UpdateProc)
|
||||
{
|
||||
SetupDiDestroyDeviceInfoList(DeviceInfoSet);
|
||||
FreeLibrary(hModule);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(!UpdateProc(NULL, HardwareIdList, InfPath, flags, &reboot))
|
||||
if (!UpdateProc(NULL, HardwareIdList, InfPath, flags, &reboot))
|
||||
{
|
||||
SetupDiDestroyDeviceInfoList(DeviceInfoSet);
|
||||
FreeLibrary(hModule);
|
||||
|
@ -443,7 +445,6 @@ DWORD
|
|||
MMSYS_InstallDevice(HDEVINFO hDevInfo, PSP_DEVINFO_DATA pspDevInfoData)
|
||||
{
|
||||
UINT Length;
|
||||
LPWSTR pBuffer;
|
||||
WCHAR szBuffer[MAX_PATH];
|
||||
HINF hInf;
|
||||
PVOID Context;
|
||||
|
@ -458,24 +459,19 @@ MMSYS_InstallDevice(HDEVINFO hDevInfo, PSP_DEVINFO_DATA pspDevInfoData)
|
|||
!IsEqualIID(&pspDevInfoData->ClassGuid, &GUID_DEVCLASS_MEDIA))
|
||||
return ERROR_DI_DO_DEFAULT;
|
||||
|
||||
Length = GetWindowsDirectoryW(szBuffer, MAX_PATH);
|
||||
if (!Length || Length >= MAX_PATH - 14)
|
||||
Length = GetWindowsDirectoryW(szBuffer, _countof(szBuffer));
|
||||
if (!Length || Length >= _countof(szBuffer) - CONST_STR_LEN(L"\\inf\\audio.inf"))
|
||||
{
|
||||
return ERROR_GEN_FAILURE;
|
||||
}
|
||||
|
||||
pBuffer = PathAddBackslashW(szBuffer);
|
||||
if (!pBuffer)
|
||||
{
|
||||
return ERROR_GEN_FAILURE;
|
||||
}
|
||||
|
||||
wcscpy(pBuffer, L"inf\\audio.inf");
|
||||
//PathCchAppend(szBuffer, _countof(szBuffer), L"inf\\audio.inf");
|
||||
StringCchCatW(szBuffer, _countof(szBuffer), L"\\inf\\audio.inf");
|
||||
|
||||
hInf = SetupOpenInfFileW(szBuffer,
|
||||
NULL,
|
||||
INF_STYLE_WIN4,
|
||||
NULL);
|
||||
INF_STYLE_WIN4,
|
||||
NULL);
|
||||
|
||||
if (hInf == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
|
@ -513,52 +509,54 @@ MMSYS_InstallDevice(HDEVINFO hDevInfo, PSP_DEVINFO_DATA pspDevInfoData)
|
|||
|
||||
if (!IsSoftwareBusPnpEnumeratorInstalled())
|
||||
{
|
||||
Length = GetWindowsDirectoryW(szBuffer, MAX_PATH);
|
||||
if (!Length || Length >= MAX_PATH - 14)
|
||||
Length = GetWindowsDirectoryW(szBuffer, _countof(szBuffer));
|
||||
if (!Length || Length >= _countof(szBuffer) - CONST_STR_LEN(L"\\inf\\machine.inf"))
|
||||
{
|
||||
return ERROR_GEN_FAILURE;
|
||||
}
|
||||
|
||||
pBuffer = PathAddBackslashW(szBuffer);
|
||||
if (!pBuffer)
|
||||
{
|
||||
return ERROR_GEN_FAILURE;
|
||||
}
|
||||
//PathCchAppend(szBuffer, _countof(szBuffer), L"inf\\machine.inf");
|
||||
StringCchCatW(szBuffer, _countof(szBuffer), L"\\inf\\machine.inf");
|
||||
|
||||
wcscpy(pBuffer, L"inf\\machine.inf");
|
||||
InstallSoftwareBusPnpEnumerator(szBuffer, L"ROOT\\SWENUM\0");
|
||||
}
|
||||
|
||||
hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT);
|
||||
hSCManager = OpenSCManagerW(NULL, NULL, SC_MANAGER_CONNECT);
|
||||
if (!hSCManager)
|
||||
{
|
||||
return ERROR_DI_DO_DEFAULT;
|
||||
}
|
||||
|
||||
hService = OpenService(hSCManager, L"AudioSrv", SERVICE_ALL_ACCESS);
|
||||
hService = OpenServiceW(hSCManager, L"AudioSrv", SERVICE_ALL_ACCESS);
|
||||
if (hService)
|
||||
{
|
||||
/* Make AudioSrv start automatically */
|
||||
ChangeServiceConfig(hService, SERVICE_NO_CHANGE, SERVICE_AUTO_START, SERVICE_NO_CHANGE, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
ChangeServiceConfigW(hService, SERVICE_NO_CHANGE, SERVICE_AUTO_START, SERVICE_NO_CHANGE, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
StartService(hService, 0, NULL);
|
||||
StartServiceW(hService, 0, NULL);
|
||||
CloseServiceHandle(hService);
|
||||
}
|
||||
CloseServiceHandle(hSCManager);
|
||||
|
||||
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Drivers32", 0, GENERIC_READ | GENERIC_WRITE, &hKey) == ERROR_SUCCESS)
|
||||
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Drivers32", 0, KEY_READ | KEY_WRITE, &hKey) == ERROR_SUCCESS)
|
||||
{
|
||||
szBuffer[Length] = '\0';
|
||||
pBuffer = PathAddBackslashW(szBuffer);
|
||||
wcscpy(pBuffer, L"system32\\wdmaud.drv");
|
||||
|
||||
for(Index = 1; Index <= 4; Index++)
|
||||
Length = GetSystemDirectoryW(szBuffer, _countof(szBuffer));
|
||||
if (!Length || Length >= _countof(szBuffer) - CONST_STR_LEN(L"\\wdmaud.drv"))
|
||||
{
|
||||
swprintf(WaveName, L"wave%u", Index);
|
||||
RegCloseKey(hKey);
|
||||
return ERROR_DI_DO_DEFAULT;
|
||||
}
|
||||
|
||||
//PathCchAppend(szBuffer, _countof(szBuffer), L"wdmaud.drv");
|
||||
StringCchCatW(szBuffer, _countof(szBuffer), L"\\wdmaud.drv");
|
||||
|
||||
for (Index = 1; Index <= 4; Index++)
|
||||
{
|
||||
StringCchPrintfW(WaveName, _countof(WaveName), L"wave%u", Index);
|
||||
if (RegQueryValueExW(hKey, WaveName, 0, NULL, NULL, &BufferSize) != ERROR_MORE_DATA)
|
||||
{
|
||||
/* Store new audio driver entry */
|
||||
RegSetValueExW(hKey, WaveName, 0, REG_SZ, (LPBYTE)szBuffer, (wcslen(szBuffer)+1) * sizeof(WCHAR));
|
||||
RegSetValueExW(hKey, WaveName, 0, REG_SZ, (LPBYTE)szBuffer, (wcslen(szBuffer) + 1) * sizeof(WCHAR));
|
||||
break;
|
||||
}
|
||||
else
|
||||
|
@ -569,9 +567,9 @@ MMSYS_InstallDevice(HDEVINFO hDevInfo, PSP_DEVINFO_DATA pspDevInfoData)
|
|||
if (RegQueryValueExW(hKey, WaveName, 0, NULL, (LPBYTE)Buffer, &BufferSize) == ERROR_SUCCESS)
|
||||
{
|
||||
/* Make sure the buffer is zero terminated */
|
||||
Buffer[MAX_PATH-1] = L'\0';
|
||||
Buffer[_countof(Buffer) - 1] = UNICODE_NULL;
|
||||
|
||||
if (!wcsicmp(Buffer, szBuffer))
|
||||
if (!_wcsicmp(Buffer, szBuffer))
|
||||
{
|
||||
/* An entry already exists */
|
||||
break;
|
||||
|
@ -651,7 +649,7 @@ HardwareDlgProc(HWND hwndDlg,
|
|||
{
|
||||
UNREFERENCED_PARAMETER(lParam);
|
||||
UNREFERENCED_PARAMETER(wParam);
|
||||
switch(uMsg)
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
|
@ -662,7 +660,7 @@ HardwareDlgProc(HWND hwndDlg,
|
|||
/* Create the hardware page */
|
||||
DeviceCreateHardwarePageEx(hwndDlg,
|
||||
Guids,
|
||||
sizeof(Guids) / sizeof(Guids[0]),
|
||||
_countof(Guids),
|
||||
HWPD_LARGELIST);
|
||||
break;
|
||||
}
|
||||
|
@ -694,50 +692,48 @@ MmSysApplet(HWND hwnd,
|
|||
LPARAM wParam,
|
||||
LPARAM lParam)
|
||||
{
|
||||
PROPSHEETPAGE psp[5];
|
||||
PROPSHEETHEADER psh; // = { 0 };
|
||||
PROPSHEETPAGEW psp[5];
|
||||
PROPSHEETHEADERW psh; // = { 0 };
|
||||
INT nPage = 0;
|
||||
|
||||
UNREFERENCED_PARAMETER(lParam);
|
||||
UNREFERENCED_PARAMETER(wParam);
|
||||
UNREFERENCED_PARAMETER(uMsg);
|
||||
|
||||
if (uMsg == CPL_STARTWPARMSW && lParam != 0)
|
||||
nPage = _wtoi((PWSTR)lParam);
|
||||
|
||||
psh.dwSize = sizeof(PROPSHEETHEADER);
|
||||
psh.dwSize = sizeof(PROPSHEETHEADERW);
|
||||
psh.dwFlags = PSH_PROPSHEETPAGE | PSH_PROPTITLE | PSH_USEICONID | PSH_USECALLBACK;
|
||||
psh.hwndParent = hwnd;
|
||||
psh.hInstance = hApplet;
|
||||
psh.pszIcon = MAKEINTRESOURCEW(IDI_CPLICON);
|
||||
psh.pszCaption = MAKEINTRESOURCEW(IDS_CPLNAME);
|
||||
psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
|
||||
psh.nPages = _countof(psp);
|
||||
psh.nStartPage = 0;
|
||||
psh.ppsp = psp;
|
||||
psh.pfnCallback = PropSheetProc;
|
||||
|
||||
InitPropSheetPage(&psp[0], IDD_VOLUME,VolumeDlgProc);
|
||||
InitPropSheetPage(&psp[1], IDD_SOUNDS,SoundsDlgProc);
|
||||
InitPropSheetPage(&psp[2], IDD_AUDIO,AudioDlgProc);
|
||||
InitPropSheetPage(&psp[3], IDD_VOICE,VoiceDlgProc);
|
||||
InitPropSheetPage(&psp[4], IDD_HARDWARE,HardwareDlgProc);
|
||||
InitPropSheetPage(&psp[0], IDD_VOLUME, VolumeDlgProc);
|
||||
InitPropSheetPage(&psp[1], IDD_SOUNDS, SoundsDlgProc);
|
||||
InitPropSheetPage(&psp[2], IDD_AUDIO, AudioDlgProc);
|
||||
InitPropSheetPage(&psp[3], IDD_VOICE, VoiceDlgProc);
|
||||
InitPropSheetPage(&psp[4], IDD_HARDWARE, HardwareDlgProc);
|
||||
|
||||
if (nPage != 0 && nPage <= psh.nPages)
|
||||
psh.nStartPage = nPage;
|
||||
|
||||
return (LONG)(PropertySheet(&psh) != -1);
|
||||
return (LONG)(PropertySheetW(&psh) != -1);
|
||||
}
|
||||
|
||||
VOID
|
||||
InitPropSheetPage(PROPSHEETPAGE *psp,
|
||||
InitPropSheetPage(PROPSHEETPAGEW *psp,
|
||||
WORD idDlg,
|
||||
DLGPROC DlgProc)
|
||||
{
|
||||
ZeroMemory(psp, sizeof(PROPSHEETPAGE));
|
||||
psp->dwSize = sizeof(PROPSHEETPAGE);
|
||||
ZeroMemory(psp, sizeof(PROPSHEETPAGEW));
|
||||
psp->dwSize = sizeof(PROPSHEETPAGEW);
|
||||
psp->dwFlags = PSP_DEFAULT;
|
||||
psp->hInstance = hApplet;
|
||||
psp->pszTemplate = MAKEINTRESOURCE(idDlg);
|
||||
psp->pszTemplate = MAKEINTRESOURCEW(idDlg);
|
||||
psp->pfnDlgProc = DlgProc;
|
||||
}
|
||||
|
||||
|
@ -749,7 +745,7 @@ CPlApplet(HWND hwndCpl,
|
|||
LPARAM lParam1,
|
||||
LPARAM lParam2)
|
||||
{
|
||||
switch(uMsg)
|
||||
switch (uMsg)
|
||||
{
|
||||
case CPL_INIT:
|
||||
return TRUE;
|
||||
|
@ -789,28 +785,28 @@ CPlApplet(HWND hwndCpl,
|
|||
VOID WINAPI
|
||||
ShowAudioPropertySheet(HWND hwnd,
|
||||
HINSTANCE hInstance,
|
||||
LPTSTR lpszCmd,
|
||||
LPWSTR lpszCmd,
|
||||
int nCmdShow)
|
||||
{
|
||||
PROPSHEETPAGE psp[1];
|
||||
PROPSHEETHEADER psh;
|
||||
PROPSHEETPAGEW psp[1];
|
||||
PROPSHEETHEADERW psh;
|
||||
|
||||
DPRINT("ShowAudioPropertySheet()\n");
|
||||
|
||||
psh.dwSize = sizeof(PROPSHEETHEADER);
|
||||
psh.dwFlags = PSH_PROPSHEETPAGE | PSH_PROPTITLE | PSH_USEICONID | PSH_USECALLBACK;
|
||||
psh.dwSize = sizeof(PROPSHEETHEADERW);
|
||||
psh.dwFlags = PSH_PROPSHEETPAGE | PSH_PROPTITLE | PSH_USEICONID | PSH_USECALLBACK;
|
||||
psh.hwndParent = hwnd;
|
||||
psh.hInstance = hInstance;
|
||||
psh.pszIcon = MAKEINTRESOURCEW(IDI_CPLICON);
|
||||
psh.pszCaption = MAKEINTRESOURCEW(IDS_CPLNAME);
|
||||
psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
|
||||
psh.nPages = _countof(psp);
|
||||
psh.nStartPage = 0;
|
||||
psh.ppsp = psp;
|
||||
psh.pfnCallback = PropSheetProc;
|
||||
|
||||
InitPropSheetPage(&psp[0], IDD_AUDIO,AudioDlgProc);
|
||||
|
||||
PropertySheet(&psh);
|
||||
PropertySheetW(&psh);
|
||||
}
|
||||
|
||||
VOID WINAPI
|
||||
|
@ -819,29 +815,29 @@ ShowFullControlPanel(HWND hwnd,
|
|||
LPSTR lpszCmd,
|
||||
int nCmdShow)
|
||||
{
|
||||
PROPSHEETPAGE psp[5];
|
||||
PROPSHEETHEADER psh;
|
||||
PROPSHEETPAGEW psp[5];
|
||||
PROPSHEETHEADERW psh;
|
||||
|
||||
DPRINT("ShowFullControlPanel()\n");
|
||||
|
||||
psh.dwSize = sizeof(PROPSHEETHEADER);
|
||||
psh.dwFlags = PSH_PROPSHEETPAGE | PSH_PROPTITLE | PSH_USEICONID | PSH_USECALLBACK;
|
||||
psh.dwSize = sizeof(PROPSHEETHEADERW);
|
||||
psh.dwFlags = PSH_PROPSHEETPAGE | PSH_PROPTITLE | PSH_USEICONID | PSH_USECALLBACK;
|
||||
psh.hwndParent = hwnd;
|
||||
psh.hInstance = hInstance;
|
||||
psh.pszIcon = MAKEINTRESOURCEW(IDI_CPLICON);
|
||||
psh.pszCaption = MAKEINTRESOURCEW(IDS_CPLNAME);
|
||||
psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
|
||||
psh.nPages = _countof(psp);
|
||||
psh.nStartPage = 0;
|
||||
psh.ppsp = psp;
|
||||
psh.pfnCallback = PropSheetProc;
|
||||
|
||||
InitPropSheetPage(&psp[0], IDD_VOLUME,VolumeDlgProc);
|
||||
InitPropSheetPage(&psp[1], IDD_SOUNDS,SoundsDlgProc);
|
||||
InitPropSheetPage(&psp[2], IDD_AUDIO,AudioDlgProc);
|
||||
InitPropSheetPage(&psp[3], IDD_VOICE,VoiceDlgProc);
|
||||
InitPropSheetPage(&psp[4], IDD_HARDWARE,HardwareDlgProc);
|
||||
InitPropSheetPage(&psp[0], IDD_VOLUME, VolumeDlgProc);
|
||||
InitPropSheetPage(&psp[1], IDD_SOUNDS, SoundsDlgProc);
|
||||
InitPropSheetPage(&psp[2], IDD_AUDIO, AudioDlgProc);
|
||||
InitPropSheetPage(&psp[3], IDD_VOICE, VoiceDlgProc);
|
||||
InitPropSheetPage(&psp[4], IDD_HARDWARE, HardwareDlgProc);
|
||||
|
||||
PropertySheet(&psh);
|
||||
PropertySheetW(&psh);
|
||||
}
|
||||
|
||||
BOOL WINAPI
|
||||
|
@ -850,7 +846,7 @@ DllMain(HINSTANCE hinstDLL,
|
|||
LPVOID lpReserved)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(lpReserved);
|
||||
switch(dwReason)
|
||||
switch (dwReason)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
hApplet = hinstDLL;
|
||||
|
|
|
@ -14,28 +14,30 @@
|
|||
#include <winuser.h>
|
||||
#include <mmsystem.h>
|
||||
#include <cpl.h>
|
||||
#include <tchar.h>
|
||||
#include <setupapi.h>
|
||||
#include <stdlib.h>
|
||||
#include <strsafe.h>
|
||||
|
||||
#include "resource.h"
|
||||
|
||||
#define CONST_STR_LEN(str) (_countof(str) - 1)
|
||||
|
||||
//typedef LONG (CALLBACK *APPLET_PROC)(VOID);
|
||||
|
||||
typedef struct _APPLET
|
||||
{
|
||||
UINT idIcon;
|
||||
UINT idName;
|
||||
UINT idDescription;
|
||||
APPLET_PROC AppletProc;
|
||||
UINT idIcon;
|
||||
UINT idName;
|
||||
UINT idDescription;
|
||||
APPLET_PROC AppletProc;
|
||||
} APPLET, *PAPPLET;
|
||||
|
||||
extern HINSTANCE hApplet;
|
||||
|
||||
|
||||
#define DRVM_MAPPER 0x2000
|
||||
#define DRVM_MAPPER_PREFERRED_GET (DRVM_MAPPER+21)
|
||||
#define DRVM_MAPPER_PREFERRED_SET (DRVM_MAPPER+22)
|
||||
#define DRVM_MAPPER_PREFERRED_GET (DRVM_MAPPER + 21)
|
||||
#define DRVM_MAPPER_PREFERRED_SET (DRVM_MAPPER + 22)
|
||||
|
||||
#define VOLUME_MIN 0
|
||||
#define VOLUME_MAX 500
|
||||
|
@ -46,7 +48,7 @@ extern HINSTANCE hApplet;
|
|||
|
||||
VOID
|
||||
InitPropSheetPage(
|
||||
PROPSHEETPAGE *psp,
|
||||
PROPSHEETPAGEW *psp,
|
||||
WORD idDlg,
|
||||
DLGPROC DlgProc);
|
||||
|
||||
|
@ -61,17 +63,17 @@ MmSysApplet(HWND hwnd,
|
|||
INT_PTR
|
||||
CALLBACK
|
||||
SoundsDlgProc(HWND hwndDlg,
|
||||
UINT uMsg,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam);
|
||||
UINT uMsg,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam);
|
||||
|
||||
/* volume.c */
|
||||
|
||||
INT_PTR CALLBACK
|
||||
VolumeDlgProc(HWND hwndDlg,
|
||||
UINT uMsg,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam);
|
||||
UINT uMsg,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam);
|
||||
|
||||
/* voice.c */
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -26,38 +26,38 @@ OnInitDialog(
|
|||
PPAGE_DATA pPageData,
|
||||
HWND hwndDlg)
|
||||
{
|
||||
TCHAR szBuffer[256];
|
||||
MIXERLINE mxln;
|
||||
MIXERCONTROL mxc;
|
||||
MIXERLINECONTROLS mxlctrl;
|
||||
WCHAR szBuffer[256];
|
||||
MIXERLINEW mxln;
|
||||
MIXERCONTROLW mxc;
|
||||
MIXERLINECONTROLSW mxlctrl;
|
||||
MIXERCONTROLDETAILS mxcd;
|
||||
INT i, j;
|
||||
|
||||
/* Open the mixer */
|
||||
if (mixerOpen(&pPageData->hMixer, 0, PtrToUlong(hwndDlg), 0, MIXER_OBJECTF_MIXER | CALLBACK_WINDOW) != MMSYSERR_NOERROR)
|
||||
{
|
||||
MessageBox(hwndDlg, _T("Cannot open mixer"), NULL, MB_OK);
|
||||
MessageBoxW(hwndDlg, L"Cannot open mixer", NULL, MB_OK);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Retrieve the mixer information */
|
||||
mxln.cbStruct = sizeof(MIXERLINE);
|
||||
mxln.cbStruct = sizeof(MIXERLINEW);
|
||||
mxln.dwComponentType = MIXERLINE_COMPONENTTYPE_DST_SPEAKERS;
|
||||
|
||||
if (mixerGetLineInfo((HMIXEROBJ)pPageData->hMixer, &mxln, MIXER_OBJECTF_HMIXER | MIXER_GETLINEINFOF_COMPONENTTYPE) != MMSYSERR_NOERROR)
|
||||
if (mixerGetLineInfoW((HMIXEROBJ)pPageData->hMixer, &mxln, MIXER_OBJECTF_HMIXER | MIXER_GETLINEINFOF_COMPONENTTYPE) != MMSYSERR_NOERROR)
|
||||
return FALSE;
|
||||
|
||||
pPageData->volumeChannels = mxln.cChannels;
|
||||
|
||||
/* Retrieve the line information */
|
||||
mxlctrl.cbStruct = sizeof(MIXERLINECONTROLS);
|
||||
mxlctrl.cbStruct = sizeof(MIXERLINECONTROLSW);
|
||||
mxlctrl.dwLineID = mxln.dwLineID;
|
||||
mxlctrl.dwControlType = MIXERCONTROL_CONTROLTYPE_VOLUME;
|
||||
mxlctrl.cControls = 1;
|
||||
mxlctrl.cbmxctrl = sizeof(MIXERCONTROL);
|
||||
mxlctrl.cbmxctrl = sizeof(MIXERCONTROLW);
|
||||
mxlctrl.pamxctrl = &mxc;
|
||||
|
||||
if (mixerGetLineControls((HMIXEROBJ)pPageData->hMixer, &mxlctrl, MIXER_OBJECTF_HMIXER | MIXER_GETLINECONTROLSF_ONEBYTYPE) != MMSYSERR_NOERROR)
|
||||
if (mixerGetLineControlsW((HMIXEROBJ)pPageData->hMixer, &mxlctrl, MIXER_OBJECTF_HMIXER | MIXER_GETLINECONTROLSF_ONEBYTYPE) != MMSYSERR_NOERROR)
|
||||
return FALSE;
|
||||
|
||||
pPageData->volumeControlID = mxc.dwControlID;
|
||||
|
@ -80,7 +80,7 @@ OnInitDialog(
|
|||
mxcd.cbDetails = sizeof(MIXERCONTROLDETAILS_UNSIGNED);
|
||||
mxcd.paDetails = pPageData->volumeValues;
|
||||
|
||||
if (mixerGetControlDetails((HMIXEROBJ)pPageData->hMixer, &mxcd, MIXER_OBJECTF_HMIXER | MIXER_GETCONTROLDETAILSF_VALUE) != MMSYSERR_NOERROR)
|
||||
if (mixerGetControlDetailsW((HMIXEROBJ)pPageData->hMixer, &mxcd, MIXER_OBJECTF_HMIXER | MIXER_GETCONTROLDETAILSF_VALUE) != MMSYSERR_NOERROR)
|
||||
return FALSE;
|
||||
|
||||
/* Initialize the channels */
|
||||
|
@ -89,14 +89,14 @@ OnInitDialog(
|
|||
j = i * 4;
|
||||
|
||||
/* Set the channel name */
|
||||
LoadString(hApplet, IDS_SPEAKER_LEFT + i, szBuffer, _countof(szBuffer));
|
||||
SetWindowText(GetDlgItem(hwndDlg, 9472 + j), szBuffer);
|
||||
LoadStringW(hApplet, IDS_SPEAKER_LEFT + i, szBuffer, _countof(szBuffer));
|
||||
SetWindowTextW(GetDlgItem(hwndDlg, 9472 + j), szBuffer);
|
||||
|
||||
/* Initialize the channel trackbar */
|
||||
SendDlgItemMessage(hwndDlg, 9475 + j, TBM_SETRANGE, (WPARAM)TRUE, (LPARAM)MAKELONG(VOLUME_MIN, VOLUME_MAX));
|
||||
SendDlgItemMessage(hwndDlg, 9475 + j, TBM_SETTICFREQ, VOLUME_TICFREQ, 0);
|
||||
SendDlgItemMessage(hwndDlg, 9475 + j, TBM_SETPAGESIZE, 0, VOLUME_PAGESIZE);
|
||||
SendDlgItemMessage(hwndDlg, 9475 + j, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)(pPageData->volumeValues[i].dwValue - pPageData->volumeMinimum) / pPageData->volumeStep);
|
||||
SendDlgItemMessageW(hwndDlg, 9475 + j, TBM_SETRANGE, (WPARAM)TRUE, MAKELPARAM(VOLUME_MIN, VOLUME_MAX));
|
||||
SendDlgItemMessageW(hwndDlg, 9475 + j, TBM_SETTICFREQ, VOLUME_TICFREQ, 0);
|
||||
SendDlgItemMessageW(hwndDlg, 9475 + j, TBM_SETPAGESIZE, 0, VOLUME_PAGESIZE);
|
||||
SendDlgItemMessageW(hwndDlg, 9475 + j, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)(pPageData->volumeValues[i].dwValue - pPageData->volumeMinimum) / pPageData->volumeStep);
|
||||
}
|
||||
|
||||
/* Hide the unused controls */
|
||||
|
@ -130,14 +130,14 @@ OnMixerControlChange(
|
|||
mxcd.cbDetails = sizeof(MIXERCONTROLDETAILS_UNSIGNED);
|
||||
mxcd.paDetails = pPageData->volumeValues;
|
||||
|
||||
if (mixerGetControlDetails((HMIXEROBJ)pPageData->hMixer, &mxcd, MIXER_OBJECTF_HMIXER | MIXER_GETCONTROLDETAILSF_VALUE) != MMSYSERR_NOERROR)
|
||||
if (mixerGetControlDetailsW((HMIXEROBJ)pPageData->hMixer, &mxcd, MIXER_OBJECTF_HMIXER | MIXER_GETCONTROLDETAILSF_VALUE) != MMSYSERR_NOERROR)
|
||||
return;
|
||||
|
||||
for (i = 0; i < pPageData->volumeChannels; i++)
|
||||
{
|
||||
j = i * 4;
|
||||
|
||||
SendDlgItemMessage(hwndDlg, 9475 + j, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)(pPageData->volumeValues[i].dwValue - pPageData->volumeMinimum) / pPageData->volumeStep);
|
||||
SendDlgItemMessageW(hwndDlg, 9475 + j, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)(pPageData->volumeValues[i].dwValue - pPageData->volumeMinimum) / pPageData->volumeStep);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -154,14 +154,14 @@ OnHScroll(
|
|||
DWORD dwValue, dwPosition;
|
||||
INT id, idx, i, j;
|
||||
|
||||
id = (INT)GetWindowLongPtr((HWND)lParam, GWLP_ID);
|
||||
id = (INT)GetWindowLongPtrW((HWND)lParam, GWLP_ID);
|
||||
if (id < 9475 || id > 9503)
|
||||
return;
|
||||
|
||||
if ((id - 9475) % 4 != 0)
|
||||
return;
|
||||
|
||||
dwPosition = (DWORD)SendDlgItemMessage(hwndDlg, id, TBM_GETPOS, 0, 0);
|
||||
dwPosition = (DWORD)SendDlgItemMessageW(hwndDlg, id, TBM_GETPOS, 0, 0);
|
||||
|
||||
if (dwPosition == VOLUME_MIN)
|
||||
dwValue = pPageData->volumeMinimum;
|
||||
|
@ -176,7 +176,7 @@ OnHScroll(
|
|||
{
|
||||
j = 9475 + (i * 4);
|
||||
if (j != id)
|
||||
SendDlgItemMessage(hwndDlg, j, TBM_SETPOS, (WPARAM)TRUE, dwPosition);
|
||||
SendDlgItemMessageW(hwndDlg, j, TBM_SETPOS, (WPARAM)TRUE, dwPosition);
|
||||
|
||||
pPageData->volumeValues[i].dwValue = dwValue;
|
||||
}
|
||||
|
@ -235,15 +235,13 @@ SpeakerVolumeDlgProc(
|
|||
{
|
||||
PPAGE_DATA pPageData;
|
||||
|
||||
UNREFERENCED_PARAMETER(wParam);
|
||||
pPageData = (PPAGE_DATA)GetWindowLongPtrW(hwndDlg, DWLP_USER);
|
||||
|
||||
pPageData = (PPAGE_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
|
||||
|
||||
switch(uMsg)
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
pPageData = (PPAGE_DATA)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(PAGE_DATA));
|
||||
SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pPageData);
|
||||
SetWindowLongPtrW(hwndDlg, DWLP_USER, (LONG_PTR)pPageData);
|
||||
|
||||
if (pPageData)
|
||||
{
|
||||
|
@ -262,7 +260,7 @@ SpeakerVolumeDlgProc(
|
|||
|
||||
HeapFree(GetProcessHeap(), 0, pPageData);
|
||||
pPageData = NULL;
|
||||
SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)NULL);
|
||||
SetWindowLongPtrW(hwndDlg, DWLP_USER, (LONG_PTR)NULL);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -279,7 +277,7 @@ SpeakerVolumeDlgProc(
|
|||
{
|
||||
case 9504:
|
||||
if (HIWORD(wParam) == BN_CLICKED)
|
||||
pPageData->volumeSync = (SendDlgItemMessage(hwndDlg, 9504, BM_GETCHECK, 0, 0) == BST_CHECKED);
|
||||
pPageData->volumeSync = (SendDlgItemMessageW(hwndDlg, 9504, BM_GETCHECK, 0, 0) == BST_CHECKED);
|
||||
break;
|
||||
|
||||
case 9505:
|
||||
|
@ -306,16 +304,16 @@ INT_PTR
|
|||
SpeakerVolume(
|
||||
HWND hwndDlg)
|
||||
{
|
||||
PROPSHEETPAGE psp[1];
|
||||
PROPSHEETHEADER psh;
|
||||
PROPSHEETPAGEW psp[1];
|
||||
PROPSHEETHEADERW psh;
|
||||
|
||||
ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
|
||||
psh.dwSize = sizeof(PROPSHEETHEADER);
|
||||
ZeroMemory(&psh, sizeof(PROPSHEETHEADERW));
|
||||
psh.dwSize = sizeof(PROPSHEETHEADERW);
|
||||
psh.dwFlags = PSH_PROPSHEETPAGE;
|
||||
psh.hwndParent = hwndDlg;
|
||||
psh.hInstance = hApplet;
|
||||
psh.pszCaption = MAKEINTRESOURCE(IDS_SPEAKER_VOLUME);
|
||||
psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
|
||||
psh.nPages = _countof(psp);
|
||||
psh.nStartPage = 0;
|
||||
psh.ppsp = psp;
|
||||
|
||||
|
@ -324,5 +322,5 @@ SpeakerVolume(
|
|||
psp[0].hInstance = hApplet;
|
||||
psp[0].pszTitle = MAKEINTRESOURCE(IDS_SPEAKER_VOLUME);
|
||||
|
||||
return (LONG)(PropertySheet(&psh) != -1);
|
||||
return (LONG)(PropertySheetW(&psh) != -1);
|
||||
}
|
||||
|
|
|
@ -19,8 +19,7 @@ VoiceDlgProc(HWND hwndDlg,
|
|||
{
|
||||
UNREFERENCED_PARAMETER(lParam);
|
||||
UNREFERENCED_PARAMETER(wParam);
|
||||
UNREFERENCED_PARAMETER(hwndDlg);
|
||||
switch(uMsg)
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
|
|
|
@ -51,16 +51,16 @@ InitImageInfo(PIMGINFO ImgInfo)
|
|||
|
||||
ZeroMemory(ImgInfo, sizeof(*ImgInfo));
|
||||
|
||||
ImgInfo->hBitmap = LoadImage(hApplet,
|
||||
MAKEINTRESOURCE(IDB_SPEAKIMG),
|
||||
IMAGE_BITMAP,
|
||||
0,
|
||||
0,
|
||||
LR_DEFAULTCOLOR);
|
||||
ImgInfo->hBitmap = LoadImageW(hApplet,
|
||||
MAKEINTRESOURCEW(IDB_SPEAKIMG),
|
||||
IMAGE_BITMAP,
|
||||
0,
|
||||
0,
|
||||
LR_DEFAULTCOLOR);
|
||||
|
||||
if (ImgInfo->hBitmap != NULL)
|
||||
{
|
||||
GetObject(ImgInfo->hBitmap, sizeof(BITMAP), &bitmap);
|
||||
GetObjectW(ImgInfo->hBitmap, sizeof(BITMAP), &bitmap);
|
||||
|
||||
ImgInfo->cxSource = bitmap.bmWidth;
|
||||
ImgInfo->cySource = bitmap.bmHeight;
|
||||
|
@ -71,28 +71,30 @@ InitImageInfo(PIMGINFO ImgInfo)
|
|||
VOID
|
||||
GetMuteControl(PGLOBAL_DATA pGlobalData)
|
||||
{
|
||||
MIXERLINE mxln;
|
||||
MIXERCONTROL mxc;
|
||||
MIXERLINECONTROLS mxlctrl;
|
||||
MIXERLINEW mxln;
|
||||
MIXERCONTROLW mxc;
|
||||
MIXERLINECONTROLSW mxlctrl;
|
||||
|
||||
if (pGlobalData->hMixer == NULL)
|
||||
return;
|
||||
|
||||
mxln.cbStruct = sizeof(MIXERLINE);
|
||||
mxln.cbStruct = sizeof(MIXERLINEW);
|
||||
mxln.dwComponentType = MIXERLINE_COMPONENTTYPE_DST_SPEAKERS;
|
||||
|
||||
if (mixerGetLineInfo((HMIXEROBJ)pGlobalData->hMixer, &mxln, MIXER_OBJECTF_HMIXER | MIXER_GETLINEINFOF_COMPONENTTYPE)
|
||||
!= MMSYSERR_NOERROR) return;
|
||||
if (mixerGetLineInfoW((HMIXEROBJ)pGlobalData->hMixer, &mxln, MIXER_OBJECTF_HMIXER | MIXER_GETLINEINFOF_COMPONENTTYPE)
|
||||
!= MMSYSERR_NOERROR)
|
||||
return;
|
||||
|
||||
mxlctrl.cbStruct = sizeof(MIXERLINECONTROLS);
|
||||
mxlctrl.cbStruct = sizeof(MIXERLINECONTROLSW);
|
||||
mxlctrl.dwLineID = mxln.dwLineID;
|
||||
mxlctrl.dwControlType = MIXERCONTROL_CONTROLTYPE_MUTE;
|
||||
mxlctrl.cControls = 1;
|
||||
mxlctrl.cbmxctrl = sizeof(MIXERCONTROL);
|
||||
mxlctrl.cbmxctrl = sizeof(MIXERCONTROLW);
|
||||
mxlctrl.pamxctrl = &mxc;
|
||||
|
||||
if (mixerGetLineControls((HMIXEROBJ)pGlobalData->hMixer, &mxlctrl, MIXER_OBJECTF_HMIXER | MIXER_GETLINECONTROLSF_ONEBYTYPE)
|
||||
!= MMSYSERR_NOERROR) return;
|
||||
if (mixerGetLineControlsW((HMIXEROBJ)pGlobalData->hMixer, &mxlctrl, MIXER_OBJECTF_HMIXER | MIXER_GETLINECONTROLSF_ONEBYTYPE)
|
||||
!= MMSYSERR_NOERROR)
|
||||
return;
|
||||
|
||||
pGlobalData->muteControlID = mxc.dwControlID;
|
||||
}
|
||||
|
@ -114,7 +116,7 @@ GetMuteState(PGLOBAL_DATA pGlobalData)
|
|||
mxcd.cbDetails = sizeof(MIXERCONTROLDETAILS_BOOLEAN);
|
||||
mxcd.paDetails = &mxcdMute;
|
||||
|
||||
if (mixerGetControlDetails((HMIXEROBJ)pGlobalData->hMixer, &mxcd, MIXER_OBJECTF_HMIXER | MIXER_GETCONTROLDETAILSF_VALUE)
|
||||
if (mixerGetControlDetailsW((HMIXEROBJ)pGlobalData->hMixer, &mxcd, MIXER_OBJECTF_HMIXER | MIXER_GETCONTROLDETAILSF_VALUE)
|
||||
!= MMSYSERR_NOERROR)
|
||||
return;
|
||||
|
||||
|
@ -147,28 +149,28 @@ SwitchMuteState(PGLOBAL_DATA pGlobalData)
|
|||
VOID
|
||||
GetVolumeControl(PGLOBAL_DATA pGlobalData)
|
||||
{
|
||||
MIXERLINE mxln;
|
||||
MIXERCONTROL mxc;
|
||||
MIXERLINECONTROLS mxlc;
|
||||
MIXERLINEW mxln;
|
||||
MIXERCONTROLW mxc;
|
||||
MIXERLINECONTROLSW mxlc;
|
||||
|
||||
if (pGlobalData->hMixer == NULL)
|
||||
return;
|
||||
|
||||
mxln.cbStruct = sizeof(MIXERLINE);
|
||||
mxln.cbStruct = sizeof(MIXERLINEW);
|
||||
mxln.dwComponentType = MIXERLINE_COMPONENTTYPE_DST_SPEAKERS;
|
||||
if (mixerGetLineInfo((HMIXEROBJ)pGlobalData->hMixer, &mxln, MIXER_OBJECTF_HMIXER | MIXER_GETLINEINFOF_COMPONENTTYPE)
|
||||
if (mixerGetLineInfoW((HMIXEROBJ)pGlobalData->hMixer, &mxln, MIXER_OBJECTF_HMIXER | MIXER_GETLINEINFOF_COMPONENTTYPE)
|
||||
!= MMSYSERR_NOERROR)
|
||||
return;
|
||||
|
||||
pGlobalData->volumeChannels = mxln.cChannels;
|
||||
|
||||
mxlc.cbStruct = sizeof(MIXERLINECONTROLS);
|
||||
mxlc.cbStruct = sizeof(MIXERLINECONTROLSW);
|
||||
mxlc.dwLineID = mxln.dwLineID;
|
||||
mxlc.dwControlType = MIXERCONTROL_CONTROLTYPE_VOLUME;
|
||||
mxlc.cControls = 1;
|
||||
mxlc.cbmxctrl = sizeof(MIXERCONTROL);
|
||||
mxlc.cbmxctrl = sizeof(MIXERCONTROLW);
|
||||
mxlc.pamxctrl = &mxc;
|
||||
if (mixerGetLineControls((HMIXEROBJ)pGlobalData->hMixer, &mxlc, MIXER_OBJECTF_HMIXER | MIXER_GETLINECONTROLSF_ONEBYTYPE)
|
||||
if (mixerGetLineControlsW((HMIXEROBJ)pGlobalData->hMixer, &mxlc, MIXER_OBJECTF_HMIXER | MIXER_GETLINECONTROLSF_ONEBYTYPE)
|
||||
!= MMSYSERR_NOERROR)
|
||||
return;
|
||||
|
||||
|
@ -215,7 +217,7 @@ GetVolumeValue(
|
|||
mxcd.cbDetails = sizeof(MIXERCONTROLDETAILS_UNSIGNED);
|
||||
mxcd.paDetails = pGlobalData->volumePreviousValues;
|
||||
|
||||
if (mixerGetControlDetails((HMIXEROBJ)pGlobalData->hMixer, &mxcd, MIXER_OBJECTF_HMIXER | MIXER_GETCONTROLDETAILSF_VALUE)
|
||||
if (mixerGetControlDetailsW((HMIXEROBJ)pGlobalData->hMixer, &mxcd, MIXER_OBJECTF_HMIXER | MIXER_GETCONTROLDETAILSF_VALUE)
|
||||
!= MMSYSERR_NOERROR)
|
||||
return;
|
||||
|
||||
|
@ -259,7 +261,7 @@ SetVolumeValue(PGLOBAL_DATA pGlobalData,
|
|||
else
|
||||
{
|
||||
pGlobalData->volumeCurrentValues[i].dwValue =
|
||||
pGlobalData->volumePreviousValues[i].dwValue * dwVolume / pGlobalData-> maxVolume;
|
||||
pGlobalData->volumePreviousValues[i].dwValue * dwVolume / pGlobalData->maxVolume;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -331,14 +333,14 @@ VOID
|
|||
InitVolumeControls(HWND hwndDlg, PGLOBAL_DATA pGlobalData)
|
||||
{
|
||||
UINT NumMixers;
|
||||
MIXERCAPS mxc;
|
||||
TCHAR szNoDevices[256];
|
||||
MIXERCAPSW mxc;
|
||||
WCHAR szNoDevices[256];
|
||||
|
||||
LoadString(hApplet, IDS_NO_DEVICES, szNoDevices, _countof(szNoDevices));
|
||||
LoadStringW(hApplet, IDS_NO_DEVICES, szNoDevices, _countof(szNoDevices));
|
||||
|
||||
SendDlgItemMessage(hwndDlg, IDC_VOLUME_TRACKBAR, TBM_SETRANGE, (WPARAM)TRUE, (LPARAM)MAKELONG(VOLUME_MIN, VOLUME_MAX));
|
||||
SendDlgItemMessage(hwndDlg, IDC_VOLUME_TRACKBAR, TBM_SETTICFREQ, VOLUME_TICFREQ, 0);
|
||||
SendDlgItemMessage(hwndDlg, IDC_VOLUME_TRACKBAR, TBM_SETPAGESIZE, 0, VOLUME_PAGESIZE);
|
||||
SendDlgItemMessageW(hwndDlg, IDC_VOLUME_TRACKBAR, TBM_SETRANGE, (WPARAM)TRUE, (LPARAM)MAKELONG(VOLUME_MIN, VOLUME_MAX));
|
||||
SendDlgItemMessageW(hwndDlg, IDC_VOLUME_TRACKBAR, TBM_SETTICFREQ, VOLUME_TICFREQ, 0);
|
||||
SendDlgItemMessageW(hwndDlg, IDC_VOLUME_TRACKBAR, TBM_SETPAGESIZE, 0, VOLUME_PAGESIZE);
|
||||
|
||||
NumMixers = mixerGetNumDevs();
|
||||
if (!NumMixers)
|
||||
|
@ -351,21 +353,21 @@ InitVolumeControls(HWND hwndDlg, PGLOBAL_DATA pGlobalData)
|
|||
EnableWindow(GetDlgItem(hwndDlg, IDC_ADVANCED_BTN), FALSE);
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDC_SPEAKER_VOL_BTN), FALSE);
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDC_ADVANCED2_BTN), FALSE);
|
||||
SendDlgItemMessage(hwndDlg, IDC_MUTE_ICON, STM_SETIMAGE, IMAGE_ICON, (LPARAM)pGlobalData->hIconNoHW);
|
||||
SetDlgItemText(hwndDlg, IDC_DEVICE_NAME, szNoDevices);
|
||||
SendDlgItemMessageW(hwndDlg, IDC_MUTE_ICON, STM_SETIMAGE, IMAGE_ICON, (LPARAM)pGlobalData->hIconNoHW);
|
||||
SetDlgItemTextW(hwndDlg, IDC_DEVICE_NAME, szNoDevices);
|
||||
return;
|
||||
}
|
||||
|
||||
if (mixerOpen(&pGlobalData->hMixer, 0, PtrToUlong(hwndDlg), 0, MIXER_OBJECTF_MIXER | CALLBACK_WINDOW) != MMSYSERR_NOERROR)
|
||||
{
|
||||
MessageBox(hwndDlg, _T("Cannot open mixer"), NULL, MB_OK);
|
||||
MessageBoxW(hwndDlg, L"Cannot open mixer", NULL, MB_OK);
|
||||
return;
|
||||
}
|
||||
|
||||
ZeroMemory(&mxc, sizeof(MIXERCAPS));
|
||||
if (mixerGetDevCaps(PtrToUint(pGlobalData->hMixer), &mxc, sizeof(MIXERCAPS)) != MMSYSERR_NOERROR)
|
||||
ZeroMemory(&mxc, sizeof(MIXERCAPSW));
|
||||
if (mixerGetDevCapsW(PtrToUint(pGlobalData->hMixer), &mxc, sizeof(MIXERCAPSW)) != MMSYSERR_NOERROR)
|
||||
{
|
||||
MessageBox(hwndDlg, _T("mixerGetDevCaps failed"), NULL, MB_OK);
|
||||
MessageBoxW(hwndDlg, L"mixerGetDevCaps failed", NULL, MB_OK);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -377,20 +379,20 @@ InitVolumeControls(HWND hwndDlg, PGLOBAL_DATA pGlobalData)
|
|||
GetMuteState(pGlobalData);
|
||||
if (pGlobalData->muteVal)
|
||||
{
|
||||
SendDlgItemMessage(hwndDlg, IDC_MUTE_CHECKBOX, BM_SETCHECK, (WPARAM)BST_CHECKED, (LPARAM)0);
|
||||
SendDlgItemMessage(hwndDlg, IDC_MUTE_ICON, STM_SETIMAGE, IMAGE_ICON, (LPARAM)pGlobalData->hIconMuted);
|
||||
SendDlgItemMessageW(hwndDlg, IDC_MUTE_CHECKBOX, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
|
||||
SendDlgItemMessageW(hwndDlg, IDC_MUTE_ICON, STM_SETIMAGE, IMAGE_ICON, (LPARAM)pGlobalData->hIconMuted);
|
||||
}
|
||||
else
|
||||
{
|
||||
SendDlgItemMessage(hwndDlg, IDC_MUTE_CHECKBOX, BM_SETCHECK, (WPARAM)BST_UNCHECKED, (LPARAM)0);
|
||||
SendDlgItemMessage(hwndDlg, IDC_MUTE_ICON, STM_SETIMAGE, IMAGE_ICON, (LPARAM)pGlobalData->hIconUnMuted);
|
||||
SendDlgItemMessageW(hwndDlg, IDC_MUTE_CHECKBOX, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
|
||||
SendDlgItemMessageW(hwndDlg, IDC_MUTE_ICON, STM_SETIMAGE, IMAGE_ICON, (LPARAM)pGlobalData->hIconUnMuted);
|
||||
}
|
||||
|
||||
GetVolumeControl(pGlobalData);
|
||||
GetVolumeValue(pGlobalData, TRUE);
|
||||
|
||||
SendDlgItemMessage(hwndDlg, IDC_DEVICE_NAME, WM_SETTEXT, 0, (LPARAM)mxc.szPname);
|
||||
SendDlgItemMessage(hwndDlg, IDC_VOLUME_TRACKBAR, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)(pGlobalData->maxVolume - pGlobalData->volumeMinimum) / pGlobalData->volumeStep);
|
||||
SendDlgItemMessageW(hwndDlg, IDC_DEVICE_NAME, WM_SETTEXT, 0, (LPARAM)mxc.szPname);
|
||||
SendDlgItemMessageW(hwndDlg, IDC_VOLUME_TRACKBAR, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)(pGlobalData->maxVolume - pGlobalData->volumeMinimum) / pGlobalData->volumeStep);
|
||||
}
|
||||
|
||||
VOID
|
||||
|
@ -408,7 +410,7 @@ LaunchSoundControl(HWND hwndDlg)
|
|||
{
|
||||
if ((INT_PTR)ShellExecuteW(NULL, L"open", L"sndvol32.exe", NULL, NULL, SW_SHOWNORMAL) > 32)
|
||||
return;
|
||||
MessageBox(hwndDlg, _T("Cannot run sndvol32.exe"), NULL, MB_OK);
|
||||
MessageBoxW(hwndDlg, L"Cannot run sndvol32.exe", NULL, MB_OK);
|
||||
}
|
||||
|
||||
/* Volume property page dialog callback */
|
||||
|
@ -421,42 +423,40 @@ VolumeDlgProc(HWND hwndDlg,
|
|||
{
|
||||
static IMGINFO ImgInfo;
|
||||
PGLOBAL_DATA pGlobalData;
|
||||
UNREFERENCED_PARAMETER(lParam);
|
||||
UNREFERENCED_PARAMETER(wParam);
|
||||
|
||||
pGlobalData = (PGLOBAL_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
|
||||
pGlobalData = (PGLOBAL_DATA)GetWindowLongPtrW(hwndDlg, DWLP_USER);
|
||||
|
||||
switch(uMsg)
|
||||
switch (uMsg)
|
||||
{
|
||||
case MM_MIXM_LINE_CHANGE:
|
||||
{
|
||||
GetMuteState(pGlobalData);
|
||||
if (pGlobalData->muteVal)
|
||||
{
|
||||
SendDlgItemMessage(hwndDlg, IDC_MUTE_CHECKBOX, BM_SETCHECK, (WPARAM)BST_CHECKED, (LPARAM)0);
|
||||
SendDlgItemMessage(hwndDlg, IDC_MUTE_ICON, STM_SETIMAGE, IMAGE_ICON, (LPARAM)pGlobalData->hIconMuted);
|
||||
SendDlgItemMessageW(hwndDlg, IDC_MUTE_CHECKBOX, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
|
||||
SendDlgItemMessageW(hwndDlg, IDC_MUTE_ICON, STM_SETIMAGE, IMAGE_ICON, (LPARAM)pGlobalData->hIconMuted);
|
||||
}
|
||||
else
|
||||
{
|
||||
SendDlgItemMessage(hwndDlg, IDC_MUTE_CHECKBOX, BM_SETCHECK, (WPARAM)BST_UNCHECKED, (LPARAM)0);
|
||||
SendDlgItemMessage(hwndDlg, IDC_MUTE_ICON, STM_SETIMAGE, IMAGE_ICON, (LPARAM)pGlobalData->hIconUnMuted);
|
||||
SendDlgItemMessageW(hwndDlg, IDC_MUTE_CHECKBOX, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
|
||||
SendDlgItemMessageW(hwndDlg, IDC_MUTE_ICON, STM_SETIMAGE, IMAGE_ICON, (LPARAM)pGlobalData->hIconUnMuted);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MM_MIXM_CONTROL_CHANGE:
|
||||
{
|
||||
GetVolumeValue(pGlobalData, FALSE);
|
||||
SendDlgItemMessage(hwndDlg, IDC_VOLUME_TRACKBAR, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)(pGlobalData->maxVolume - pGlobalData->volumeMinimum) / pGlobalData->volumeStep);
|
||||
SendDlgItemMessageW(hwndDlg, IDC_VOLUME_TRACKBAR, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)(pGlobalData->maxVolume - pGlobalData->volumeMinimum) / pGlobalData->volumeStep);
|
||||
break;
|
||||
}
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
pGlobalData = (GLOBAL_DATA*) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(GLOBAL_DATA));
|
||||
SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData);
|
||||
pGlobalData = (PGLOBAL_DATA)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(GLOBAL_DATA));
|
||||
SetWindowLongPtrW(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData);
|
||||
|
||||
pGlobalData->hIconUnMuted = LoadImage(hApplet, MAKEINTRESOURCE(IDI_CPLICON), IMAGE_ICON, 32, 32, LR_DEFAULTCOLOR);
|
||||
pGlobalData->hIconMuted = LoadImage(hApplet, MAKEINTRESOURCE(IDI_MUTED_ICON), IMAGE_ICON, 32, 32, LR_DEFAULTCOLOR);
|
||||
pGlobalData->hIconNoHW = LoadImage(hApplet, MAKEINTRESOURCE(IDI_NO_HW), IMAGE_ICON, 32, 32, LR_DEFAULTCOLOR);
|
||||
pGlobalData->hIconUnMuted = LoadImageW(hApplet, MAKEINTRESOURCEW(IDI_CPLICON), IMAGE_ICON, 32, 32, LR_DEFAULTCOLOR);
|
||||
pGlobalData->hIconMuted = LoadImageW(hApplet, MAKEINTRESOURCEW(IDI_MUTED_ICON), IMAGE_ICON, 32, 32, LR_DEFAULTCOLOR);
|
||||
pGlobalData->hIconNoHW = LoadImageW(hApplet, MAKEINTRESOURCEW(IDI_NO_HW), IMAGE_ICON, 32, 32, LR_DEFAULTCOLOR);
|
||||
|
||||
InitImageInfo(&ImgInfo);
|
||||
InitVolumeControls(hwndDlg, pGlobalData);
|
||||
|
@ -466,8 +466,8 @@ VolumeDlgProc(HWND hwndDlg,
|
|||
case WM_DRAWITEM:
|
||||
{
|
||||
LPDRAWITEMSTRUCT lpDrawItem;
|
||||
lpDrawItem = (LPDRAWITEMSTRUCT) lParam;
|
||||
if(lpDrawItem->CtlID == IDC_SPEAKIMG)
|
||||
lpDrawItem = (LPDRAWITEMSTRUCT)lParam;
|
||||
if (lpDrawItem->CtlID == IDC_SPEAKIMG)
|
||||
{
|
||||
HDC hdcMem;
|
||||
LONG left;
|
||||
|
@ -504,11 +504,11 @@ VolumeDlgProc(HWND hwndDlg,
|
|||
SwitchMuteState(pGlobalData);
|
||||
if (pGlobalData->muteVal)
|
||||
{
|
||||
SendDlgItemMessage(hwndDlg, IDC_MUTE_ICON, STM_SETIMAGE, IMAGE_ICON, (LPARAM)pGlobalData->hIconMuted);
|
||||
SendDlgItemMessageW(hwndDlg, IDC_MUTE_ICON, STM_SETIMAGE, IMAGE_ICON, (LPARAM)pGlobalData->hIconMuted);
|
||||
}
|
||||
else
|
||||
{
|
||||
SendDlgItemMessage(hwndDlg, IDC_MUTE_ICON, STM_SETIMAGE, IMAGE_ICON, (LPARAM)pGlobalData->hIconUnMuted);
|
||||
SendDlgItemMessageW(hwndDlg, IDC_MUTE_ICON, STM_SETIMAGE, IMAGE_ICON, (LPARAM)pGlobalData->hIconUnMuted);
|
||||
}
|
||||
|
||||
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
|
||||
|
@ -544,12 +544,12 @@ VolumeDlgProc(HWND hwndDlg,
|
|||
break;
|
||||
|
||||
case TB_ENDTRACK:
|
||||
PlaySound((LPCTSTR)SND_ALIAS_SYSTEMDEFAULT, NULL, SND_ALIAS_ID | SND_ASYNC);
|
||||
PlaySoundW((LPCWSTR)SND_ALIAS_SYSTEMDEFAULT, NULL, SND_ALIAS_ID | SND_ASYNC);
|
||||
break;
|
||||
|
||||
default:
|
||||
SetVolumeValue(pGlobalData,
|
||||
(DWORD)SendDlgItemMessage(hwndDlg, IDC_VOLUME_TRACKBAR, TBM_GETPOS, 0, 0));
|
||||
(DWORD)SendDlgItemMessageW(hwndDlg, IDC_VOLUME_TRACKBAR, TBM_GETPOS, 0, 0));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue