https://git.reactos.org/?p=reactos.git;a=commitdiff;h=781c247bd3c5aeee79952…
commit 781c247bd3c5aeee799527db2ce06e15f794b0a4
Author: Thamatip Chitpong <tangaming123456(a)outlook.com>
AuthorDate: Thu Sep 15 00:06:22 2022 +0700
Commit: GitHub <noreply(a)github.com>
CommitDate: Wed Sep 14 20:06:22 2022 +0300
[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(a)reactos.org>
Reviewed-by: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
Reviewed-by: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
Reviewed-by: Stanislav Motylkov <x86corez(a)gmail.com>
---
dll/cpl/mmsys/audio.c | 102 +++++----
dll/cpl/mmsys/mmsys.c | 224 +++++++++---------
dll/cpl/mmsys/mmsys.h | 30 +--
dll/cpl/mmsys/sounds.c | 519 ++++++++++++++++++++++--------------------
dll/cpl/mmsys/speakervolume.c | 68 +++---
dll/cpl/mmsys/voice.c | 3 +-
dll/cpl/mmsys/volume.c | 134 +++++------
7 files changed, 558 insertions(+), 522 deletions(-)
diff --git a/dll/cpl/mmsys/audio.c b/dll/cpl/mmsys/audio.c
index 5fdaa6b0ead..2841cc2127c 100644
--- a/dll/cpl/mmsys/audio.c
+++ b/dll/cpl/mmsys/audio.c
@@ -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;
diff --git a/dll/cpl/mmsys/mmsys.c b/dll/cpl/mmsys/mmsys.c
index 325604db4a1..78bdc57078b 100644
--- a/dll/cpl/mmsys/mmsys.c
+++ b/dll/cpl/mmsys/mmsys.c
@@ -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"(a)mmsys.cpl,-%u",-%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"(a)mmsys.cpl,-%u",-%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"(a)mmsys.cpl,-%u",-%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"(a)mmsys.cpl,-%u",-%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");
+ Length = GetSystemDirectoryW(szBuffer, _countof(szBuffer));
+ if (!Length || Length >= _countof(szBuffer) -
CONST_STR_LEN(L"\\wdmaud.drv"))
+ {
+ RegCloseKey(hKey);
+ return ERROR_DI_DO_DEFAULT;
+ }
- for(Index = 1; Index <= 4; Index++)
+ //PathCchAppend(szBuffer, _countof(szBuffer), L"wdmaud.drv");
+ StringCchCatW(szBuffer, _countof(szBuffer), L"\\wdmaud.drv");
+
+ for (Index = 1; Index <= 4; Index++)
{
- swprintf(WaveName, L"wave%u", 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;
diff --git a/dll/cpl/mmsys/mmsys.h b/dll/cpl/mmsys/mmsys.h
index 8c601c2db8e..ac4829f78b6 100644
--- a/dll/cpl/mmsys/mmsys.h
+++ b/dll/cpl/mmsys/mmsys.h
@@ -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 */
diff --git a/dll/cpl/mmsys/sounds.c b/dll/cpl/mmsys/sounds.c
index b59814d92a1..57461ea09ec 100644
--- a/dll/cpl/mmsys/sounds.c
+++ b/dll/cpl/mmsys/sounds.c
@@ -13,24 +13,23 @@
#include <commdlg.h>
#include <windowsx.h>
-#include <strsafe.h>
#include <debug.h>
typedef struct _LABEL_MAP
{
- TCHAR *szName;
- TCHAR *szDesc;
- TCHAR *szIcon;
+ PWCHAR szName;
+ PWCHAR szDesc;
+ PWCHAR szIcon;
struct _APP_MAP *AppMap;
struct _LABEL_MAP *Next;
} LABEL_MAP, *PLABEL_MAP;
typedef struct _APP_MAP
{
- TCHAR szName[MAX_PATH];
- TCHAR szDesc[MAX_PATH];
- TCHAR szIcon[MAX_PATH];
+ WCHAR szName[MAX_PATH];
+ WCHAR szDesc[MAX_PATH];
+ WCHAR szIcon[MAX_PATH];
struct _APP_MAP *Next;
PLABEL_MAP LabelMap;
@@ -40,20 +39,20 @@ typedef struct _LABEL_CONTEXT
{
PLABEL_MAP LabelMap;
PAPP_MAP AppMap;
- TCHAR szValue[MAX_PATH];
+ WCHAR szValue[MAX_PATH];
struct _LABEL_CONTEXT *Next;
} LABEL_CONTEXT, *PLABEL_CONTEXT;
typedef struct _SOUND_SCHEME_CONTEXT
{
- TCHAR szName[MAX_PATH];
- TCHAR szDesc[MAX_PATH];
+ WCHAR szName[MAX_PATH];
+ WCHAR szDesc[MAX_PATH];
PLABEL_CONTEXT LabelContext;
} SOUND_SCHEME_CONTEXT, *PSOUND_SCHEME_CONTEXT;
typedef struct _GLOBAL_DATA
{
- TCHAR szDefault[MAX_PATH];
+ WCHAR szDefault[MAX_PATH];
HIMAGELIST hSoundsImageList;
PLABEL_MAP pLabelMap;
PAPP_MAP pAppMap;
@@ -64,7 +63,7 @@ typedef struct _GLOBAL_DATA
/* A filter string is a list separated by NULL and ends with double NULLs. */
LPWSTR MakeFilter(LPWSTR psz)
{
- WCHAR *pch;
+ PWCHAR pch;
ASSERT(psz[0] != UNICODE_NULL &&
psz[wcslen(psz) - 1] == L'|');
@@ -79,7 +78,7 @@ LPWSTR MakeFilter(LPWSTR psz)
return psz;
}
-PLABEL_MAP FindLabel(PGLOBAL_DATA pGlobalData, PAPP_MAP pAppMap, TCHAR * szName)
+PLABEL_MAP FindLabel(PGLOBAL_DATA pGlobalData, PAPP_MAP pAppMap, PWCHAR szName)
{
PLABEL_MAP pMap = pGlobalData->pLabelMap;
@@ -87,7 +86,7 @@ PLABEL_MAP FindLabel(PGLOBAL_DATA pGlobalData, PAPP_MAP pAppMap, TCHAR *
szName)
{
ASSERT(pMap);
ASSERT(pMap->szName);
- if (!_tcscmp(pMap->szName, szName))
+ if (!wcscmp(pMap->szName, szName))
return pMap;
pMap = pMap->Next;
@@ -99,7 +98,7 @@ PLABEL_MAP FindLabel(PGLOBAL_DATA pGlobalData, PAPP_MAP pAppMap, TCHAR *
szName)
{
ASSERT(pMap);
ASSERT(pMap->szName);
- if (!_tcscmp(pMap->szName, szName))
+ if (!wcscmp(pMap->szName, szName))
return pMap;
pMap = pMap->Next;
@@ -109,7 +108,7 @@ PLABEL_MAP FindLabel(PGLOBAL_DATA pGlobalData, PAPP_MAP pAppMap, TCHAR
* szName)
if (!pMap)
return NULL;
- pMap->szName = pMap->szDesc = _tcsdup(szName);
+ pMap->szName = pMap->szDesc = _wcsdup(szName);
if (!pMap->szName)
{
HeapFree(GetProcessHeap(), 0, pMap);
@@ -154,18 +153,28 @@ FreeLabelMap(PGLOBAL_DATA pGlobalData)
while (pGlobalData->pLabelMap)
{
pCurMap = pGlobalData->pLabelMap->Next;
+
+ /* Prevent double freeing (for "FindLabel") */
+ if (pGlobalData->pLabelMap->szName !=
pGlobalData->pLabelMap->szDesc)
+ {
+ free(pGlobalData->pLabelMap->szName);
+ }
+
+ free(pGlobalData->pLabelMap->szDesc);
+ free(pGlobalData->pLabelMap->szIcon);
+
HeapFree(GetProcessHeap(), 0, pGlobalData->pLabelMap);
pGlobalData->pLabelMap = pCurMap;
}
}
-PAPP_MAP FindApp(PGLOBAL_DATA pGlobalData, TCHAR *szName)
+PAPP_MAP FindApp(PGLOBAL_DATA pGlobalData, PWCHAR szName)
{
PAPP_MAP pMap = pGlobalData->pAppMap;
while (pMap)
{
- if (!_tcscmp(pMap->szName, szName))
+ if (!wcscmp(pMap->szName, szName))
return pMap;
pMap = pMap->Next;
@@ -188,7 +197,7 @@ FreeAppMap(PGLOBAL_DATA pGlobalData)
}
}
-PLABEL_CONTEXT FindLabelContext(PGLOBAL_DATA pGlobalData, PSOUND_SCHEME_CONTEXT
pSoundScheme, TCHAR * AppName, TCHAR * LabelName)
+PLABEL_CONTEXT FindLabelContext(PGLOBAL_DATA pGlobalData, PSOUND_SCHEME_CONTEXT
pSoundScheme, PWCHAR AppName, PWCHAR LabelName)
{
PLABEL_CONTEXT pLabelContext;
@@ -199,7 +208,7 @@ PLABEL_CONTEXT FindLabelContext(PGLOBAL_DATA pGlobalData,
PSOUND_SCHEME_CONTEXT
ASSERT(pLabelContext->AppMap);
ASSERT(pLabelContext->LabelMap);
- if (!_tcsicmp(pLabelContext->AppMap->szName, AppName) &&
!_tcsicmp(pLabelContext->LabelMap->szName, LabelName))
+ if (!_wcsicmp(pLabelContext->AppMap->szName, AppName) &&
!_wcsicmp(pLabelContext->LabelMap->szName, LabelName))
{
return pLabelContext;
}
@@ -214,7 +223,7 @@ PLABEL_CONTEXT FindLabelContext(PGLOBAL_DATA pGlobalData,
PSOUND_SCHEME_CONTEXT
pLabelContext->LabelMap = FindLabel(pGlobalData, pLabelContext->AppMap,
LabelName);
ASSERT(pLabelContext->AppMap);
ASSERT(pLabelContext->LabelMap);
- pLabelContext->szValue[0] = _T('\0');
+ pLabelContext->szValue[0] = UNICODE_NULL;
pLabelContext->Next = pSoundScheme->LabelContext;
pSoundScheme->LabelContext = pLabelContext;
@@ -223,42 +232,42 @@ PLABEL_CONTEXT FindLabelContext(PGLOBAL_DATA pGlobalData,
PSOUND_SCHEME_CONTEXT
BOOL
-LoadEventLabel(PGLOBAL_DATA pGlobalData, HKEY hKey, TCHAR * szSubKey)
+LoadEventLabel(PGLOBAL_DATA pGlobalData, HKEY hKey, PWCHAR szSubKey)
{
HKEY hSubKey;
DWORD cbValue;
- TCHAR szDesc[MAX_PATH];
- TCHAR szData[MAX_PATH];
+ WCHAR szDesc[MAX_PATH];
+ WCHAR szData[MAX_PATH];
PLABEL_MAP pMap;
- if (RegOpenKeyEx(hKey,
- szSubKey,
- 0,
- KEY_READ,
- &hSubKey) != ERROR_SUCCESS)
+ if (RegOpenKeyExW(hKey,
+ szSubKey,
+ 0,
+ KEY_READ,
+ &hSubKey) != ERROR_SUCCESS)
{
return FALSE;
}
cbValue = sizeof(szDesc);
- if (RegQueryValueEx(hSubKey,
- NULL,
- NULL,
- NULL,
- (LPBYTE)szDesc,
- &cbValue) != ERROR_SUCCESS)
+ if (RegQueryValueExW(hSubKey,
+ NULL,
+ NULL,
+ NULL,
+ (LPBYTE)szDesc,
+ &cbValue) != ERROR_SUCCESS)
{
RegCloseKey(hSubKey);
return FALSE;
}
cbValue = sizeof(szData);
- if (RegQueryValueEx(hSubKey,
- _T("DispFileName"),
- NULL,
- NULL,
- (LPBYTE)szData,
- &cbValue) != ERROR_SUCCESS)
+ if (RegQueryValueExW(hSubKey,
+ L"DispFileName",
+ NULL,
+ NULL,
+ (LPBYTE)szData,
+ &cbValue) != ERROR_SUCCESS)
{
RegCloseKey(hSubKey);
return FALSE;
@@ -270,9 +279,9 @@ LoadEventLabel(PGLOBAL_DATA pGlobalData, HKEY hKey, TCHAR * szSubKey)
return FALSE;
}
- pMap->szName = _tcsdup(szSubKey);
- pMap->szDesc = _tcsdup(szDesc);
- pMap->szIcon = _tcsdup(szData);
+ pMap->szName = _wcsdup(szSubKey);
+ pMap->szDesc = _wcsdup(szDesc);
+ pMap->szIcon = _wcsdup(szData);
if (pGlobalData->pLabelMap)
{
@@ -293,15 +302,15 @@ LoadEventLabels(PGLOBAL_DATA pGlobalData)
{
HKEY hSubKey;
DWORD dwCurKey;
- TCHAR szName[MAX_PATH];
+ WCHAR szName[MAX_PATH];
DWORD dwName;
DWORD dwResult;
DWORD dwCount;
- if (RegOpenKeyEx(HKEY_CURRENT_USER,
- _T("AppEvents\\EventLabels"),
- 0,
- KEY_READ,
- &hSubKey) != ERROR_SUCCESS)
+ if (RegOpenKeyExW(HKEY_CURRENT_USER,
+ L"AppEvents\\EventLabels",
+ 0,
+ KEY_READ,
+ &hSubKey) != ERROR_SUCCESS)
{
return FALSE;
}
@@ -311,14 +320,14 @@ LoadEventLabels(PGLOBAL_DATA pGlobalData)
do
{
dwName = _countof(szName);
- dwResult = RegEnumKeyEx(hSubKey,
- dwCurKey,
- szName,
- &dwName,
- NULL,
- NULL,
- NULL,
- NULL);
+ dwResult = RegEnumKeyExW(hSubKey,
+ dwCurKey,
+ szName,
+ &dwName,
+ NULL,
+ NULL,
+ NULL,
+ NULL);
if (dwResult == ERROR_SUCCESS)
{
@@ -337,30 +346,30 @@ LoadEventLabels(PGLOBAL_DATA pGlobalData)
BOOL
-AddSoundProfile(HWND hwndDlg, HKEY hKey, TCHAR * szSubKey, BOOL SetDefault)
+AddSoundProfile(HWND hwndDlg, HKEY hKey, PWCHAR szSubKey, BOOL SetDefault)
{
HKEY hSubKey;
- TCHAR szValue[MAX_PATH];
+ WCHAR szValue[MAX_PATH];
DWORD cbValue, dwResult;
LRESULT lResult;
PSOUND_SCHEME_CONTEXT pScheme;
- if (RegOpenKeyEx(hKey,
- szSubKey,
- 0,
- KEY_READ,
- &hSubKey) != ERROR_SUCCESS)
+ if (RegOpenKeyExW(hKey,
+ szSubKey,
+ 0,
+ KEY_READ,
+ &hSubKey) != ERROR_SUCCESS)
{
return FALSE;
}
cbValue = sizeof(szValue);
- dwResult = RegQueryValueEx(hSubKey,
- NULL,
- NULL,
- NULL,
- (LPBYTE)szValue,
- &cbValue);
+ dwResult = RegQueryValueExW(hSubKey,
+ NULL,
+ NULL,
+ NULL,
+ (LPBYTE)szValue,
+ &cbValue);
RegCloseKey(hSubKey);
if (dwResult != ERROR_SUCCESS)
@@ -380,8 +389,8 @@ AddSoundProfile(HWND hwndDlg, HKEY hKey, TCHAR * szSubKey, BOOL
SetDefault)
return FALSE;
}
- StringCchCopy(pScheme->szDesc, MAX_PATH, szValue);
- StringCchCopy(pScheme->szName, MAX_PATH, szSubKey);
+ StringCchCopyW(pScheme->szDesc, _countof(pScheme->szDesc), szValue);
+ StringCchCopyW(pScheme->szName, _countof(pScheme->szName), szSubKey);
/* Associate the value with the item in the combobox */
ComboBox_SetItemData(GetDlgItem(hwndDlg, IDC_SOUND_SCHEME), lResult, pScheme);
@@ -402,24 +411,24 @@ EnumerateSoundProfiles(PGLOBAL_DATA pGlobalData, HWND hwndDlg, HKEY
hKey)
HKEY hSubKey;
DWORD dwName, dwCurKey, dwResult, dwNumSchemes;
DWORD cbDefault;
- TCHAR szName[MAX_PATH];
+ WCHAR szName[MAX_PATH];
cbDefault = sizeof(pGlobalData->szDefault);
- if (RegQueryValueEx(hKey,
- NULL,
- NULL,
- NULL,
- (LPBYTE)pGlobalData->szDefault,
- &cbDefault) != ERROR_SUCCESS)
+ if (RegQueryValueExW(hKey,
+ NULL,
+ NULL,
+ NULL,
+ (LPBYTE)pGlobalData->szDefault,
+ &cbDefault) != ERROR_SUCCESS)
{
return FALSE;
}
- if (RegOpenKeyEx(hKey,
- _T("Names"),
- 0,
- KEY_READ,
- &hSubKey) != ERROR_SUCCESS)
+ if (RegOpenKeyExW(hKey,
+ L"Names",
+ 0,
+ KEY_READ,
+ &hSubKey) != ERROR_SUCCESS)
{
return FALSE;
}
@@ -429,18 +438,18 @@ EnumerateSoundProfiles(PGLOBAL_DATA pGlobalData, HWND hwndDlg, HKEY
hKey)
do
{
dwName = _countof(szName);
- dwResult = RegEnumKeyEx(hSubKey,
- dwCurKey,
- szName,
- &dwName,
- NULL,
- NULL,
- NULL,
- NULL);
+ dwResult = RegEnumKeyExW(hSubKey,
+ dwCurKey,
+ szName,
+ &dwName,
+ NULL,
+ NULL,
+ NULL,
+ NULL);
if (dwResult == ERROR_SUCCESS)
{
- if (AddSoundProfile(hwndDlg, hSubKey, szName, (!_tcsicmp(szName,
pGlobalData->szDefault))))
+ if (AddSoundProfile(hwndDlg, hSubKey, szName, (!_wcsicmp(szName,
pGlobalData->szDefault))))
{
dwNumSchemes++;
}
@@ -454,7 +463,7 @@ EnumerateSoundProfiles(PGLOBAL_DATA pGlobalData, HWND hwndDlg, HKEY
hKey)
}
-PSOUND_SCHEME_CONTEXT FindSoundProfile(HWND hwndDlg, TCHAR * szName)
+PSOUND_SCHEME_CONTEXT FindSoundProfile(HWND hwndDlg, PWCHAR szName)
{
LRESULT lCount, lIndex, lResult;
PSOUND_SCHEME_CONTEXT pScheme;
@@ -476,7 +485,7 @@ PSOUND_SCHEME_CONTEXT FindSoundProfile(HWND hwndDlg, TCHAR * szName)
}
pScheme = (PSOUND_SCHEME_CONTEXT)lResult;
- if (!_tcsicmp(pScheme->szName, szName))
+ if (!_wcsicmp(pScheme->szName, szName))
{
return pScheme;
}
@@ -520,37 +529,35 @@ FreeSoundProfiles(HWND hwndDlg)
}
BOOL
-ImportSoundLabel(PGLOBAL_DATA pGlobalData, HWND hwndDlg, HKEY hKey, TCHAR * szProfile,
TCHAR * szLabelName, TCHAR * szAppName, PAPP_MAP AppMap, PLABEL_MAP LabelMap)
+ImportSoundLabel(PGLOBAL_DATA pGlobalData, HWND hwndDlg, HKEY hKey, PWCHAR szProfile,
PWCHAR szLabelName, PWCHAR szAppName, PAPP_MAP AppMap, PLABEL_MAP LabelMap)
{
HKEY hSubKey;
- TCHAR szValue[MAX_PATH];
- TCHAR szBuffer[MAX_PATH];
+ WCHAR szValue[MAX_PATH];
+ WCHAR szBuffer[MAX_PATH];
DWORD cbValue, cchLength;
PSOUND_SCHEME_CONTEXT pScheme;
PLABEL_CONTEXT pLabelContext;
BOOL bCurrentProfile, bActiveProfile;
- //MessageBox(hwndDlg, szProfile, szLabelName, MB_OK);
+ bCurrentProfile = !_wcsicmp(szProfile, L".Current");
+ bActiveProfile = !_wcsicmp(szProfile, pGlobalData->szDefault);
- bCurrentProfile = !_tcsicmp(szProfile, _T(".Current"));
- bActiveProfile = !_tcsicmp(szProfile, pGlobalData->szDefault);
-
- if (RegOpenKeyEx(hKey,
- szProfile,
- 0,
- KEY_READ,
- &hSubKey) != ERROR_SUCCESS)
+ if (RegOpenKeyExW(hKey,
+ szProfile,
+ 0,
+ KEY_READ,
+ &hSubKey) != ERROR_SUCCESS)
{
return FALSE;
}
cbValue = sizeof(szValue);
- if (RegQueryValueEx(hSubKey,
- NULL,
- NULL,
- NULL,
- (LPBYTE)szValue,
- &cbValue) != ERROR_SUCCESS)
+ if (RegQueryValueExW(hSubKey,
+ NULL,
+ NULL,
+ NULL,
+ (LPBYTE)szValue,
+ &cbValue) != ERROR_SUCCESS)
{
return FALSE;
}
@@ -562,12 +569,11 @@ ImportSoundLabel(PGLOBAL_DATA pGlobalData, HWND hwndDlg, HKEY hKey,
TCHAR * szPr
if (!pScheme)
{
- //MessageBox(hwndDlg, szProfile, _T("no profile!!"), MB_OK);
return FALSE;
}
pLabelContext = FindLabelContext(pGlobalData, pScheme, AppMap->szName,
LabelMap->szName);
- cchLength = ExpandEnvironmentStrings(szValue, szBuffer, _countof(szBuffer));
+ cchLength = ExpandEnvironmentStringsW(szValue, szBuffer, _countof(szBuffer));
if (cchLength == 0 || cchLength > _countof(szBuffer))
{
/* fixme */
@@ -575,30 +581,30 @@ ImportSoundLabel(PGLOBAL_DATA pGlobalData, HWND hwndDlg, HKEY hKey,
TCHAR * szPr
}
if (bCurrentProfile)
- _tcscpy(pLabelContext->szValue, szBuffer);
+ StringCchCopyW(pLabelContext->szValue, _countof(pLabelContext->szValue),
szBuffer);
else if (!bActiveProfile)
- _tcscpy(pLabelContext->szValue, szBuffer);
+ StringCchCopyW(pLabelContext->szValue, _countof(pLabelContext->szValue),
szBuffer);
return TRUE;
}
DWORD
-ImportSoundEntry(PGLOBAL_DATA pGlobalData, HWND hwndDlg, HKEY hKey, TCHAR * szLabelName,
TCHAR * szAppName, PAPP_MAP pAppMap)
+ImportSoundEntry(PGLOBAL_DATA pGlobalData, HWND hwndDlg, HKEY hKey, PWCHAR szLabelName,
PWCHAR szAppName, PAPP_MAP pAppMap)
{
HKEY hSubKey;
DWORD dwNumProfiles;
DWORD dwCurKey;
DWORD dwResult;
DWORD dwProfile;
- TCHAR szProfile[MAX_PATH];
+ WCHAR szProfile[MAX_PATH];
PLABEL_MAP pLabel;
- if (RegOpenKeyEx(hKey,
- szLabelName,
- 0,
- KEY_READ,
- &hSubKey) != ERROR_SUCCESS)
+ if (RegOpenKeyExW(hKey,
+ szLabelName,
+ 0,
+ KEY_READ,
+ &hSubKey) != ERROR_SUCCESS)
{
return FALSE;
}
@@ -616,14 +622,14 @@ ImportSoundEntry(PGLOBAL_DATA pGlobalData, HWND hwndDlg, HKEY hKey,
TCHAR * szLa
do
{
dwProfile = _countof(szProfile);
- dwResult = RegEnumKeyEx(hSubKey,
- dwCurKey,
- szProfile,
- &dwProfile,
- NULL,
- NULL,
- NULL,
- NULL);
+ dwResult = RegEnumKeyExW(hSubKey,
+ dwCurKey,
+ szProfile,
+ &dwProfile,
+ NULL,
+ NULL,
+ NULL,
+ NULL);
if (dwResult == ERROR_SUCCESS)
{
@@ -643,42 +649,40 @@ ImportSoundEntry(PGLOBAL_DATA pGlobalData, HWND hwndDlg, HKEY hKey,
TCHAR * szLa
DWORD
-ImportAppProfile(PGLOBAL_DATA pGlobalData, HWND hwndDlg, HKEY hKey, TCHAR * szAppName)
+ImportAppProfile(PGLOBAL_DATA pGlobalData, HWND hwndDlg, HKEY hKey, PWCHAR szAppName)
{
HKEY hSubKey;
- TCHAR szDefault[MAX_PATH];
+ WCHAR szDefault[MAX_PATH];
DWORD cbValue;
DWORD dwCurKey;
DWORD dwResult;
DWORD dwNumEntry;
DWORD dwName;
- TCHAR szName[MAX_PATH];
- TCHAR szIcon[MAX_PATH];
+ WCHAR szName[MAX_PATH];
+ WCHAR szIcon[MAX_PATH];
PAPP_MAP AppMap;
- //MessageBox(hwndDlg, szAppName, _T("Importing...\n"), MB_OK);
-
AppMap = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(APP_MAP));
if (!AppMap)
return 0;
- if (RegOpenKeyEx(hKey,
- szAppName,
- 0,
- KEY_READ,
- &hSubKey) != ERROR_SUCCESS)
+ if (RegOpenKeyExW(hKey,
+ szAppName,
+ 0,
+ KEY_READ,
+ &hSubKey) != ERROR_SUCCESS)
{
HeapFree(GetProcessHeap(), 0, AppMap);
return 0;
}
cbValue = sizeof(szDefault);
- if (RegQueryValueEx(hSubKey,
- NULL,
- NULL,
- NULL,
- (LPBYTE)szDefault,
- &cbValue) != ERROR_SUCCESS)
+ if (RegQueryValueExW(hSubKey,
+ NULL,
+ NULL,
+ NULL,
+ (LPBYTE)szDefault,
+ &cbValue) != ERROR_SUCCESS)
{
RegCloseKey(hSubKey);
HeapFree(GetProcessHeap(), 0, AppMap);
@@ -686,20 +690,20 @@ ImportAppProfile(PGLOBAL_DATA pGlobalData, HWND hwndDlg, HKEY hKey,
TCHAR * szAp
}
cbValue = sizeof(szIcon);
- if (RegQueryValueEx(hSubKey,
- _T("DispFileName"),
- NULL,
- NULL,
- (LPBYTE)szIcon,
- &cbValue) != ERROR_SUCCESS)
+ if (RegQueryValueExW(hSubKey,
+ L"DispFileName",
+ NULL,
+ NULL,
+ (LPBYTE)szIcon,
+ &cbValue) != ERROR_SUCCESS)
{
- szIcon[0] = _T('\0');
+ szIcon[0] = UNICODE_NULL;
}
/* initialize app map */
- _tcscpy(AppMap->szName, szAppName);
- _tcscpy(AppMap->szDesc, szDefault);
- _tcscpy(AppMap->szIcon, szIcon);
+ StringCchCopyW(AppMap->szName, _countof(AppMap->szName), szAppName);
+ StringCchCopyW(AppMap->szDesc, _countof(AppMap->szDesc), szDefault);
+ StringCchCopyW(AppMap->szIcon, _countof(AppMap->szIcon), szIcon);
AppMap->Next = pGlobalData->pAppMap;
pGlobalData->pAppMap = AppMap;
@@ -710,14 +714,14 @@ ImportAppProfile(PGLOBAL_DATA pGlobalData, HWND hwndDlg, HKEY hKey,
TCHAR * szAp
do
{
dwName = _countof(szName);
- dwResult = RegEnumKeyEx(hSubKey,
- dwCurKey,
- szName,
- &dwName,
- NULL,
- NULL,
- NULL,
- NULL);
+ dwResult = RegEnumKeyExW(hSubKey,
+ dwCurKey,
+ szName,
+ &dwName,
+ NULL,
+ NULL,
+ NULL,
+ NULL);
if (dwResult == ERROR_SUCCESS)
{
if (ImportSoundEntry(pGlobalData, hwndDlg, hSubKey, szName, szAppName,
AppMap))
@@ -739,14 +743,14 @@ ImportSoundProfiles(PGLOBAL_DATA pGlobalData, HWND hwndDlg, HKEY
hKey)
DWORD dwCurKey;
DWORD dwResult;
DWORD dwNumApps;
- TCHAR szName[MAX_PATH];
+ WCHAR szName[MAX_PATH];
HKEY hSubKey;
- if (RegOpenKeyEx(hKey,
- _T("Apps"),
- 0,
- KEY_READ,
- &hSubKey) != ERROR_SUCCESS)
+ if (RegOpenKeyExW(hKey,
+ L"Apps",
+ 0,
+ KEY_READ,
+ &hSubKey) != ERROR_SUCCESS)
{
return FALSE;
}
@@ -755,10 +759,10 @@ ImportSoundProfiles(PGLOBAL_DATA pGlobalData, HWND hwndDlg, HKEY
hKey)
dwCurKey = 0;
do
{
- dwResult = RegEnumKey(hSubKey,
- dwCurKey,
- szName,
- _countof(szName));
+ dwResult = RegEnumKeyW(hSubKey,
+ dwCurKey,
+ szName,
+ _countof(szName));
if (dwResult == ERROR_SUCCESS)
{
@@ -782,11 +786,11 @@ LoadSoundProfiles(PGLOBAL_DATA pGlobalData, HWND hwndDlg)
HKEY hSubKey;
DWORD dwNumSchemes;
- if (RegOpenKeyEx(HKEY_CURRENT_USER,
- _T("AppEvents\\Schemes"),
- 0,
- KEY_READ,
- &hSubKey) != ERROR_SUCCESS)
+ if (RegOpenKeyExW(HKEY_CURRENT_USER,
+ L"AppEvents\\Schemes",
+ 0,
+ KEY_READ,
+ &hSubKey) != ERROR_SUCCESS)
{
return FALSE;
}
@@ -796,7 +800,6 @@ LoadSoundProfiles(PGLOBAL_DATA pGlobalData, HWND hwndDlg)
if (dwNumSchemes)
{
- //MessageBox(hwndDlg, _T("importing sound profiles..."), NULL, MB_OK);
ImportSoundProfiles(pGlobalData, hwndDlg, hSubKey);
}
@@ -808,34 +811,30 @@ LoadSoundProfiles(PGLOBAL_DATA pGlobalData, HWND hwndDlg)
BOOL
LoadSoundFiles(HWND hwndDlg)
{
- TCHAR szList[256];
+ WCHAR szList[256];
WCHAR szPath[MAX_PATH];
- WCHAR * ptr;
+ PWCHAR ptr;
WIN32_FIND_DATAW FileData;
HANDLE hFile;
LRESULT lResult;
UINT length;
/* Add no sound listview item */
- if (LoadString(hApplet, IDS_NO_SOUND, szList, _countof(szList)))
+ if (LoadStringW(hApplet, IDS_NO_SOUND, szList, _countof(szList)))
{
- szList[_countof(szList) - 1] = TEXT('\0');
+ szList[_countof(szList) - 1] = UNICODE_NULL;
ComboBox_AddString(GetDlgItem(hwndDlg, IDC_SOUND_LIST), szList);
}
/* Load sound files */
- length = GetWindowsDirectoryW(szPath, MAX_PATH);
- if (length == 0 || length >= MAX_PATH - 9)
+ length = GetWindowsDirectoryW(szPath, _countof(szPath));
+ if (length == 0 || length >= _countof(szPath) -
CONST_STR_LEN(L"\\media\\*"))
{
return FALSE;
}
- if (szPath[length-1] != L'\\')
- {
- szPath[length] = L'\\';
- length++;
- }
- wcscpy(&szPath[length], L"media\\*");
- length += 7;
+
+ //PathCchAppend(szPath, _countof(szPath), L"media\\*");
+ StringCchCatW(szPath, _countof(szPath), L"\\media\\*");
hFile = FindFirstFileW(szPath, &FileData);
if (hFile == INVALID_HANDLE_VALUE)
@@ -857,10 +856,12 @@ LoadSoundFiles(HWND hwndDlg)
{
ptr = FileData.cFileName;
}
- lResult = SendDlgItemMessageW(hwndDlg, IDC_SOUND_LIST, CB_ADDSTRING, (WPARAM)0,
(LPARAM)ptr);
+ lResult = SendDlgItemMessageW(hwndDlg, IDC_SOUND_LIST, CB_ADDSTRING, 0,
(LPARAM)ptr);
if (lResult != CB_ERR)
{
- wcscpy(&szPath[length-1], FileData.cFileName);
+ StringCchCopyW(szPath + (length + CONST_STR_LEN(L"\\media\\")),
+ _countof(szPath) - (length +
CONST_STR_LEN(L"\\media\\")),
+ FileData.cFileName);
SendDlgItemMessageW(hwndDlg, IDC_SOUND_LIST, CB_SETITEMDATA, (WPARAM)lResult,
(LPARAM)_wcsdup(szPath));
}
} while (FindNextFileW(hFile, &FileData) != 0);
@@ -869,6 +870,31 @@ LoadSoundFiles(HWND hwndDlg)
return TRUE;
}
+static
+VOID
+FreeSoundFiles(HWND hwndDlg)
+{
+ LRESULT lCount, lIndex, lResult;
+ PWCHAR pSoundPath;
+ HWND hwndComboBox;
+
+ hwndComboBox = GetDlgItem(hwndDlg, IDC_SOUND_LIST);
+ lCount = ComboBox_GetCount(hwndComboBox);
+ if (lCount == CB_ERR)
+ return;
+
+ for (lIndex = 0; lIndex < lCount; lIndex++)
+ {
+ lResult = ComboBox_GetItemData(hwndComboBox, lIndex);
+ if (lResult == CB_ERR)
+ {
+ continue;
+ }
+
+ pSoundPath = (PWCHAR)lResult;
+ free(pSoundPath);
+ }
+}
BOOL
ShowSoundScheme(PGLOBAL_DATA pGlobalData, HWND hwndDlg)
@@ -879,7 +905,7 @@ ShowSoundScheme(PGLOBAL_DATA pGlobalData, HWND hwndDlg)
PLABEL_MAP pLabelMap;
PLABEL_CONTEXT pLabelContext;
HWND hDlgCtrl, hList;
- TVINSERTSTRUCT tvItem;
+ TVINSERTSTRUCTW tvItem;
HTREEITEM hTreeItem;
hDlgCtrl = GetDlgItem(hwndDlg, IDC_SOUND_SCHEME);
@@ -890,20 +916,20 @@ ShowSoundScheme(PGLOBAL_DATA pGlobalData, HWND hwndDlg)
TreeView_SetImageList(hList, pGlobalData->hSoundsImageList, TVSIL_NORMAL);
}
- lIndex = SendMessage(hDlgCtrl, CB_GETCURSEL, (WPARAM)0, (LPARAM)0);
+ lIndex = SendMessageW(hDlgCtrl, CB_GETCURSEL, 0, 0);
if (lIndex == CB_ERR)
{
return FALSE;
}
- lIndex = SendMessage(hDlgCtrl, CB_GETITEMDATA, (WPARAM)lIndex, (LPARAM)0);
+ lIndex = SendMessageW(hDlgCtrl, CB_GETITEMDATA, (WPARAM)lIndex, 0);
if (lIndex == CB_ERR)
{
return FALSE;
}
pScheme = (PSOUND_SCHEME_CONTEXT)lIndex;
- _tcscpy(pGlobalData->szDefault, pScheme->szName);
+ StringCchCopyW(pGlobalData->szDefault, _countof(pGlobalData->szDefault),
pScheme->szName);
pAppMap = pGlobalData->pAppMap;
while (pAppMap)
@@ -935,7 +961,7 @@ ShowSoundScheme(PGLOBAL_DATA pGlobalData, HWND hwndDlg)
tvItem.item.state = TVIS_EXPANDED;
tvItem.item.stateMask = TVIS_EXPANDED;
tvItem.item.pszText = pLabelMap->szDesc;
- if (pLabelContext->szValue && _tcslen(pLabelContext->szValue)
> 0)
+ if (pLabelContext->szValue && wcslen(pLabelContext->szValue)
> 0)
{
tvItem.item.iImage = IMAGE_SOUND_ASSIGNED;
tvItem.item.iSelectedImage = IMAGE_SOUND_ASSIGNED;
@@ -961,44 +987,45 @@ BOOL
ApplyChanges(HWND hwndDlg)
{
HKEY hKey, hSubKey;
+ DWORD dwType;
LRESULT lIndex;
PSOUND_SCHEME_CONTEXT pScheme;
HWND hDlgCtrl;
PLABEL_CONTEXT pLabelContext;
- TCHAR Buffer[100];
+ WCHAR Buffer[100];
hDlgCtrl = GetDlgItem(hwndDlg, IDC_SOUND_SCHEME);
- lIndex = SendMessage(hDlgCtrl, CB_GETCURSEL, (WPARAM)0, (LPARAM)0);
+ lIndex = SendMessageW(hDlgCtrl, CB_GETCURSEL, 0, 0);
if (lIndex == CB_ERR)
{
return FALSE;
}
- lIndex = SendMessage(hDlgCtrl, CB_GETITEMDATA, (WPARAM)lIndex, (LPARAM)0);
+ lIndex = SendMessageW(hDlgCtrl, CB_GETITEMDATA, (WPARAM)lIndex, 0);
if (lIndex == CB_ERR)
{
return FALSE;
}
pScheme = (PSOUND_SCHEME_CONTEXT)lIndex;
- if (RegOpenKeyEx(HKEY_CURRENT_USER,
- _T("AppEvents\\Schemes"),
- 0,
- KEY_WRITE,
- &hKey) != ERROR_SUCCESS)
+ if (RegOpenKeyExW(HKEY_CURRENT_USER,
+ L"AppEvents\\Schemes",
+ 0,
+ KEY_WRITE,
+ &hKey) != ERROR_SUCCESS)
{
return FALSE;
}
- RegSetValueEx(hKey, NULL, 0, REG_SZ, (LPBYTE)pScheme->szName,
(_tcslen(pScheme->szName) +1) * sizeof(TCHAR));
+ RegSetValueExW(hKey, NULL, 0, REG_SZ, (LPBYTE)pScheme->szName,
(wcslen(pScheme->szName) + 1) * sizeof(WCHAR));
RegCloseKey(hKey);
- if (RegOpenKeyEx(HKEY_CURRENT_USER,
- _T("AppEvents\\Schemes\\Apps"),
- 0,
- KEY_WRITE,
- &hKey) != ERROR_SUCCESS)
+ if (RegOpenKeyExW(HKEY_CURRENT_USER,
+ L"AppEvents\\Schemes\\Apps",
+ 0,
+ KEY_WRITE,
+ &hKey) != ERROR_SUCCESS)
{
return FALSE;
}
@@ -1007,11 +1034,12 @@ ApplyChanges(HWND hwndDlg)
while (pLabelContext)
{
- _stprintf(Buffer, _T("%s\\%s\\.Current"),
pLabelContext->AppMap->szName, pLabelContext->LabelMap->szName);
+ StringCchPrintfW(Buffer, _countof(Buffer), L"%s\\%s\\.Current",
pLabelContext->AppMap->szName, pLabelContext->LabelMap->szName);
- if (RegOpenKeyEx(hKey, Buffer, 0, KEY_WRITE, &hSubKey) == ERROR_SUCCESS)
+ if (RegOpenKeyExW(hKey, Buffer, 0, KEY_WRITE, &hSubKey) == ERROR_SUCCESS)
{
- RegSetValueEx(hSubKey, NULL, 0, REG_EXPAND_SZ,
(LPBYTE)pLabelContext->szValue, (_tcslen(pLabelContext->szValue) +1) *
sizeof(TCHAR));
+ dwType = (wcschr(pLabelContext->szValue, L'%') ? REG_EXPAND_SZ :
REG_SZ);
+ RegSetValueExW(hSubKey, NULL, 0, dwType, (LPBYTE)pLabelContext->szValue,
(wcslen(pLabelContext->szValue) + 1) * sizeof(WCHAR));
RegCloseKey(hSubKey);
}
@@ -1019,7 +1047,7 @@ ApplyChanges(HWND hwndDlg)
}
RegCloseKey(hKey);
- SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, (LONG_PTR)PSNRET_NOERROR);
+ SetWindowLongPtrW(hwndDlg, DWLP_MSGRESULT, (LONG_PTR)PSNRET_NOERROR);
return TRUE;
}
@@ -1101,20 +1129,20 @@ SoundsDlgProc(HWND hwndDlg,
LPWSTR pFileName;
LRESULT lResult;
- pGlobalData = (PGLOBAL_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
+ pGlobalData = (PGLOBAL_DATA)GetWindowLongPtrW(hwndDlg, DWLP_USER);
switch (uMsg)
{
case WM_INITDIALOG:
{
pGlobalData = (PGLOBAL_DATA)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(GLOBAL_DATA));
- SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData);
+ SetWindowLongPtrW(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData);
pGlobalData->NumWavOut = waveOutGetNumDevs();
- SendMessage(GetDlgItem(hwndDlg, IDC_PLAY_SOUND),
- BM_SETIMAGE,(WPARAM)IMAGE_ICON,
- (LPARAM)(HANDLE)LoadIcon(hApplet,
MAKEINTRESOURCE(IDI_PLAY_ICON)));
+ SendMessageW(GetDlgItem(hwndDlg, IDC_PLAY_SOUND),
+ BM_SETIMAGE, (WPARAM)IMAGE_ICON,
+ (LPARAM)(HANDLE)LoadIconW(hApplet,
MAKEINTRESOURCEW(IDI_PLAY_ICON)));
pGlobalData->hSoundsImageList = InitImageList(IDI_SOUND_SECTION,
IDI_SOUND_ASSIGNED,
@@ -1142,7 +1170,7 @@ SoundsDlgProc(HWND hwndDlg,
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hwndDlg;
ofn.lpstrFile = filename;
- ofn.lpstrFile[0] = L'\0';
+ ofn.lpstrFile[0] = UNICODE_NULL;
ofn.nMaxFile = _countof(filename);
LoadStringW(hApplet, IDS_WAVE_FILES_FILTER, szFilter,
_countof(szFilter));
ofn.lpstrFilter = MakeFilter(szFilter);
@@ -1152,7 +1180,7 @@ SoundsDlgProc(HWND hwndDlg,
ofn.lpstrInitialDir = L"%SystemRoot%\\Media";
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
- if (GetOpenFileNameW(&ofn) != FALSE)
+ if (GetOpenFileNameW(&ofn))
{
// FIXME search if list already contains that sound
@@ -1162,12 +1190,12 @@ SoundsDlgProc(HWND hwndDlg,
pFileName++;
// add to list
- lResult = SendDlgItemMessageW(hwndDlg, IDC_SOUND_LIST,
CB_ADDSTRING, (WPARAM)0, (LPARAM)pFileName);
+ lResult = SendDlgItemMessageW(hwndDlg, IDC_SOUND_LIST,
CB_ADDSTRING, 0, (LPARAM)pFileName);
if (lResult != CB_ERR)
{
// add path and select item
SendDlgItemMessageW(hwndDlg, IDC_SOUND_LIST, CB_SETITEMDATA,
(WPARAM)lResult, (LPARAM)_wcsdup(filename));
- SendDlgItemMessageW(hwndDlg, IDC_SOUND_LIST, CB_SETCURSEL,
(WPARAM)lResult, (LPARAM)0);
+ SendDlgItemMessageW(hwndDlg, IDC_SOUND_LIST, CB_SETCURSEL,
(WPARAM)lResult, 0);
}
}
break;
@@ -1184,7 +1212,7 @@ SoundsDlgProc(HWND hwndDlg,
lIndex = ComboBox_GetItemData(GetDlgItem(hwndDlg, IDC_SOUND_LIST),
lIndex);
if (lIndex != CB_ERR)
{
- PlaySound((TCHAR*)lIndex, NULL, SND_FILENAME);
+ PlaySoundW((PWCHAR)lIndex, NULL, SND_FILENAME);
}
break;
}
@@ -1192,7 +1220,7 @@ SoundsDlgProc(HWND hwndDlg,
{
if (HIWORD(wParam) == CBN_SELENDOK)
{
- (void)TreeView_DeleteAllItems(GetDlgItem(hwndDlg,
IDC_SCHEME_LIST));
+ TreeView_DeleteAllItems(GetDlgItem(hwndDlg, IDC_SCHEME_LIST));
ShowSoundScheme(pGlobalData, hwndDlg);
EnableWindow(GetDlgItem(hwndDlg, IDC_SOUND_LIST), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_TEXT_SOUND), FALSE);
@@ -1208,7 +1236,7 @@ SoundsDlgProc(HWND hwndDlg,
{
PLABEL_CONTEXT pLabelContext;
HTREEITEM hItem;
- TVITEM item;
+ TVITEMW item;
LRESULT lIndex;
hItem = TreeView_GetSelection(GetDlgItem(hwndDlg,
IDC_SCHEME_LIST));
@@ -1247,12 +1275,12 @@ SoundsDlgProc(HWND hwndDlg,
EnableWindow(GetDlgItem(hwndDlg, IDC_PLAY_SOUND),
FALSE);
}
- pLabelContext->szValue[0] = L'\0';
+ pLabelContext->szValue[0] = UNICODE_NULL;
break;
}
- if (_tcsicmp(pLabelContext->szValue, (TCHAR*)lResult) ||
(lIndex != pLabelContext->szValue[0]))
+ if (_wcsicmp(pLabelContext->szValue, (PWCHAR)lResult) ||
(lIndex != pLabelContext->szValue[0]))
{
/* Update the tree view item image */
item.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE;
@@ -1265,10 +1293,10 @@ SoundsDlgProc(HWND hwndDlg,
///
/// Should store in current member
///
- _tcscpy(pLabelContext->szValue, (TCHAR*)lResult);
+ StringCchCopyW(pLabelContext->szValue,
_countof(pLabelContext->szValue), (PWCHAR)lResult);
}
- if (_tcslen((TCHAR*)lResult) && lIndex != 0
&& pGlobalData->NumWavOut != 0)
+ if (wcslen((PWCHAR)lResult) && lIndex != 0 &&
pGlobalData->NumWavOut != 0)
{
EnableWindow(GetDlgItem(hwndDlg, IDC_PLAY_SOUND), TRUE);
}
@@ -1285,6 +1313,7 @@ SoundsDlgProc(HWND hwndDlg,
}
case WM_DESTROY:
{
+ FreeSoundFiles(hwndDlg);
FreeSoundProfiles(hwndDlg);
FreeAppMap(pGlobalData);
FreeLabelMap(pGlobalData);
@@ -1296,11 +1325,11 @@ SoundsDlgProc(HWND hwndDlg,
case WM_NOTIFY:
{
PLABEL_CONTEXT pLabelContext;
- TCHAR * ptr;
+ PWCHAR ptr;
LPNMHDR lpnm = (LPNMHDR)lParam;
- switch(lpnm->code)
+ switch (lpnm->code)
{
case PSN_APPLY:
{
@@ -1309,7 +1338,7 @@ SoundsDlgProc(HWND hwndDlg,
}
case TVN_SELCHANGED:
{
- LPNMTREEVIEW nm = (LPNMTREEVIEW)lParam;
+ LPNMTREEVIEWW nm = (LPNMTREEVIEWW)lParam;
LRESULT lCount, lIndex, lResult;
pLabelContext = (PLABEL_CONTEXT)nm->itemNew.lParam;
@@ -1326,7 +1355,7 @@ SoundsDlgProc(HWND hwndDlg,
EnableWindow(GetDlgItem(hwndDlg, IDC_TEXT_SOUND), TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE_SOUND), TRUE);
- if (_tcslen(pLabelContext->szValue) == 0)
+ if (wcslen(pLabelContext->szValue) == 0)
{
lIndex = ComboBox_SetCurSel(GetDlgItem(hwndDlg, IDC_SOUND_LIST),
0);
EnableWindow(GetDlgItem(hwndDlg, IDC_PLAY_SOUND), FALSE);
@@ -1343,14 +1372,14 @@ SoundsDlgProc(HWND hwndDlg,
if (lResult == CB_ERR || lResult == 0)
continue;
- if (!_tcscmp((TCHAR*)lResult, pLabelContext->szValue))
+ if (!wcscmp((PWCHAR)lResult, pLabelContext->szValue))
{
ComboBox_SetCurSel(GetDlgItem(hwndDlg, IDC_SOUND_LIST),
lIndex);
return FALSE;
}
}
- ptr = _tcsrchr(pLabelContext->szValue, _T('\\'));
+ ptr = wcsrchr(pLabelContext->szValue, L'\\');
if (ptr)
{
ptr++;
@@ -1363,7 +1392,7 @@ SoundsDlgProc(HWND hwndDlg,
lIndex = ComboBox_AddString(GetDlgItem(hwndDlg, IDC_SOUND_LIST),
ptr);
if (lIndex != CB_ERR)
{
- ComboBox_SetItemData(GetDlgItem(hwndDlg, IDC_SOUND_LIST), lIndex,
_tcsdup(pLabelContext->szValue));
+ ComboBox_SetItemData(GetDlgItem(hwndDlg, IDC_SOUND_LIST), lIndex,
_wcsdup(pLabelContext->szValue));
ComboBox_SetCurSel(GetDlgItem(hwndDlg, IDC_SOUND_LIST), lIndex);
}
break;
diff --git a/dll/cpl/mmsys/speakervolume.c b/dll/cpl/mmsys/speakervolume.c
index 8b887fdc6a7..aa5e6916eee 100644
--- a/dll/cpl/mmsys/speakervolume.c
+++ b/dll/cpl/mmsys/speakervolume.c
@@ -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);
}
diff --git a/dll/cpl/mmsys/voice.c b/dll/cpl/mmsys/voice.c
index 29ce9756f7e..ca8abc6463e 100644
--- a/dll/cpl/mmsys/voice.c
+++ b/dll/cpl/mmsys/voice.c
@@ -19,8 +19,7 @@ VoiceDlgProc(HWND hwndDlg,
{
UNREFERENCED_PARAMETER(lParam);
UNREFERENCED_PARAMETER(wParam);
- UNREFERENCED_PARAMETER(hwndDlg);
- switch(uMsg)
+ switch (uMsg)
{
case WM_INITDIALOG:
{
diff --git a/dll/cpl/mmsys/volume.c b/dll/cpl/mmsys/volume.c
index 17c86808269..f18a9f57b7e 100644
--- a/dll/cpl/mmsys/volume.c
+++ b/dll/cpl/mmsys/volume.c
@@ -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;
}
}