mirror of
https://github.com/reactos/reactos.git
synced 2025-07-31 11:51:58 +00:00
- don't write more bytes to the reg key than is required. fixes bug 2402
- use unicode explicitly See issue #2402 for more details. svn path=/trunk/; revision=28056
This commit is contained in:
parent
59bf5f271d
commit
1fb9e7536b
1 changed files with 77 additions and 77 deletions
|
@ -13,8 +13,8 @@ static VOID
|
||||||
CreateNTPServerList(HWND hwnd)
|
CreateNTPServerList(HWND hwnd)
|
||||||
{
|
{
|
||||||
HWND hList;
|
HWND hList;
|
||||||
TCHAR szValName[MAX_VALUE_NAME];
|
WCHAR szValName[MAX_VALUE_NAME];
|
||||||
TCHAR szData[256];
|
WCHAR szData[256];
|
||||||
DWORD dwIndex = 0;
|
DWORD dwIndex = 0;
|
||||||
DWORD dwValSize;
|
DWORD dwValSize;
|
||||||
DWORD dwNameSize;
|
DWORD dwNameSize;
|
||||||
|
@ -25,8 +25,8 @@ CreateNTPServerList(HWND hwnd)
|
||||||
hList = GetDlgItem(hwnd,
|
hList = GetDlgItem(hwnd,
|
||||||
IDC_SERVERLIST);
|
IDC_SERVERLIST);
|
||||||
|
|
||||||
lRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
|
lRet = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
||||||
_T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\DateTime\\Servers"),
|
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\DateTime\\Servers",
|
||||||
0,
|
0,
|
||||||
KEY_QUERY_VALUE,
|
KEY_QUERY_VALUE,
|
||||||
&hKey);
|
&hKey);
|
||||||
|
@ -35,30 +35,30 @@ CreateNTPServerList(HWND hwnd)
|
||||||
|
|
||||||
while (TRUE)
|
while (TRUE)
|
||||||
{
|
{
|
||||||
dwValSize = MAX_VALUE_NAME * sizeof(TCHAR);
|
dwValSize = MAX_VALUE_NAME * sizeof(WCHAR);
|
||||||
szValName[0] = '\0';
|
szValName[0] = L'\0';
|
||||||
lRet = RegEnumValue(hKey,
|
lRet = RegEnumValueW(hKey,
|
||||||
dwIndex,
|
dwIndex,
|
||||||
szValName,
|
szValName,
|
||||||
&dwValSize,
|
&dwValSize,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
(LPBYTE)szData,
|
(LPBYTE)szData,
|
||||||
&dwNameSize);
|
&dwNameSize);
|
||||||
if (lRet == ERROR_SUCCESS)
|
if (lRet == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
/* get date from default reg value */
|
/* get date from default reg value */
|
||||||
if (_tcscmp(szValName, _T("")) == 0) // if (Index == 0)
|
if (wcscmp(szValName, L"") == 0) // if (Index == 0)
|
||||||
{
|
{
|
||||||
dwDefault = _ttoi(szData);
|
dwDefault = _wtoi(szData);
|
||||||
dwIndex++;
|
dwIndex++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SendMessage(hList,
|
SendMessageW(hList,
|
||||||
CB_ADDSTRING,
|
CB_ADDSTRING,
|
||||||
0,
|
0,
|
||||||
(LPARAM)szData);
|
(LPARAM)szData);
|
||||||
dwIndex++;
|
dwIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,10 +75,10 @@ CreateNTPServerList(HWND hwnd)
|
||||||
* combo boxes count from 0 */
|
* combo boxes count from 0 */
|
||||||
dwDefault--;
|
dwDefault--;
|
||||||
|
|
||||||
SendMessage(hList,
|
SendMessageW(hList,
|
||||||
CB_SETCURSEL,
|
CB_SETCURSEL,
|
||||||
dwDefault,
|
dwDefault,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
RegCloseKey(hKey);
|
RegCloseKey(hKey);
|
||||||
}
|
}
|
||||||
|
@ -91,13 +91,13 @@ SetNTPServer(HWND hwnd)
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
HWND hList;
|
HWND hList;
|
||||||
UINT uSel;
|
UINT uSel;
|
||||||
TCHAR szSel[4];
|
WCHAR szSel[4];
|
||||||
LONG lRet;
|
LONG lRet;
|
||||||
|
|
||||||
hList = GetDlgItem(hwnd,
|
hList = GetDlgItem(hwnd,
|
||||||
IDC_SERVERLIST);
|
IDC_SERVERLIST);
|
||||||
|
|
||||||
uSel = (UINT)SendMessage(hList, CB_GETCURSEL, 0, 0);
|
uSel = (UINT)SendMessageW(hList, CB_GETCURSEL, 0, 0);
|
||||||
|
|
||||||
/* server reg entries count from 1,
|
/* server reg entries count from 1,
|
||||||
* combo boxes count from 0 */
|
* combo boxes count from 0 */
|
||||||
|
@ -106,11 +106,11 @@ SetNTPServer(HWND hwnd)
|
||||||
/* convert to wide char */
|
/* convert to wide char */
|
||||||
_itow(uSel, szSel, 10);
|
_itow(uSel, szSel, 10);
|
||||||
|
|
||||||
lRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
|
lRet = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
||||||
_T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\DateTime\\Servers"),
|
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\DateTime\\Servers",
|
||||||
0,
|
0,
|
||||||
KEY_SET_VALUE,
|
KEY_SET_VALUE,
|
||||||
&hKey);
|
&hKey);
|
||||||
if (lRet != ERROR_SUCCESS)
|
if (lRet != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
DisplayWin32Error(lRet);
|
DisplayWin32Error(lRet);
|
||||||
|
@ -118,11 +118,11 @@ SetNTPServer(HWND hwnd)
|
||||||
}
|
}
|
||||||
|
|
||||||
lRet = RegSetValueExW(hKey,
|
lRet = RegSetValueExW(hKey,
|
||||||
_T(""),
|
L"",
|
||||||
0,
|
0,
|
||||||
REG_SZ,
|
REG_SZ,
|
||||||
(LPBYTE)szSel,
|
(LPBYTE)szSel,
|
||||||
sizeof(szSel));
|
(wcslen(szSel) + 1) * sizeof(WCHAR));
|
||||||
if (lRet != ERROR_SUCCESS)
|
if (lRet != ERROR_SUCCESS)
|
||||||
DisplayWin32Error(lRet);
|
DisplayWin32Error(lRet);
|
||||||
|
|
||||||
|
@ -132,43 +132,43 @@ SetNTPServer(HWND hwnd)
|
||||||
|
|
||||||
/* get the domain name from the registry */
|
/* get the domain name from the registry */
|
||||||
static BOOL
|
static BOOL
|
||||||
GetNTPServerAddress(LPTSTR *lpAddress)
|
GetNTPServerAddress(LPWSTR *lpAddress)
|
||||||
{
|
{
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
TCHAR szSel[4];
|
WCHAR szSel[4];
|
||||||
DWORD dwSize;
|
DWORD dwSize;
|
||||||
LONG lRet;
|
LONG lRet;
|
||||||
|
|
||||||
lRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
|
lRet = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
||||||
_T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\DateTime\\Servers"),
|
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\DateTime\\Servers",
|
||||||
0,
|
0,
|
||||||
KEY_QUERY_VALUE,
|
KEY_QUERY_VALUE,
|
||||||
&hKey);
|
&hKey);
|
||||||
if (lRet != ERROR_SUCCESS)
|
if (lRet != ERROR_SUCCESS)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
/* Get data from default value */
|
/* Get data from default value */
|
||||||
dwSize = 4 * sizeof(TCHAR);
|
dwSize = 4 * sizeof(WCHAR);
|
||||||
lRet = RegQueryValueEx(hKey,
|
lRet = RegQueryValueExW(hKey,
|
||||||
_T(""),
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
(LPBYTE)szSel,
|
(LPBYTE)szSel,
|
||||||
&dwSize);
|
&dwSize);
|
||||||
if (lRet != ERROR_SUCCESS)
|
if (lRet != ERROR_SUCCESS)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
dwSize = 0;
|
dwSize = 0;
|
||||||
lRet = RegQueryValueEx(hKey,
|
lRet = RegQueryValueExW(hKey,
|
||||||
szSel,
|
szSel,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
&dwSize);
|
&dwSize);
|
||||||
if (lRet != ERROR_SUCCESS)
|
if (lRet != ERROR_SUCCESS)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
(*lpAddress) = (LPTSTR)HeapAlloc(GetProcessHeap(),
|
(*lpAddress) = (LPWSTR)HeapAlloc(GetProcessHeap(),
|
||||||
0,
|
0,
|
||||||
dwSize);
|
dwSize);
|
||||||
if ((*lpAddress) == NULL)
|
if ((*lpAddress) == NULL)
|
||||||
|
@ -177,12 +177,12 @@ GetNTPServerAddress(LPTSTR *lpAddress)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
lRet = RegQueryValueEx(hKey,
|
lRet = RegQueryValueExW(hKey,
|
||||||
szSel,
|
szSel,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
(LPBYTE)*lpAddress,
|
(LPBYTE)*lpAddress,
|
||||||
&dwSize);
|
&dwSize);
|
||||||
if (lRet != ERROR_SUCCESS)
|
if (lRet != ERROR_SUCCESS)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ fail:
|
||||||
static ULONG
|
static ULONG
|
||||||
GetTimeFromServer(VOID)
|
GetTimeFromServer(VOID)
|
||||||
{
|
{
|
||||||
LPTSTR lpAddress = NULL;
|
LPWSTR lpAddress = NULL;
|
||||||
ULONG ulTime = 0;
|
ULONG ulTime = 0;
|
||||||
|
|
||||||
if (GetNTPServerAddress(&lpAddress))
|
if (GetNTPServerAddress(&lpAddress))
|
||||||
|
@ -269,7 +269,7 @@ EnableDialogText(HWND hwnd)
|
||||||
BOOL bChecked;
|
BOOL bChecked;
|
||||||
UINT uCheck;
|
UINT uCheck;
|
||||||
|
|
||||||
uCheck = (UINT)SendDlgItemMessage(hwnd, IDC_AUTOSYNC, BM_GETCHECK, 0, 0);
|
uCheck = (UINT)SendDlgItemMessageW(hwnd, IDC_AUTOSYNC, BM_GETCHECK, 0, 0);
|
||||||
bChecked = (uCheck == BST_CHECKED) ? TRUE : FALSE;
|
bChecked = (uCheck == BST_CHECKED) ? TRUE : FALSE;
|
||||||
|
|
||||||
EnableWindow(GetDlgItem(hwnd, IDC_SERVERTEXT), bChecked);
|
EnableWindow(GetDlgItem(hwnd, IDC_SERVERTEXT), bChecked);
|
||||||
|
@ -284,25 +284,25 @@ static VOID
|
||||||
GetSyncSetting(HWND hwnd)
|
GetSyncSetting(HWND hwnd)
|
||||||
{
|
{
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
TCHAR szData[8];
|
WCHAR szData[8];
|
||||||
DWORD dwSize;
|
DWORD dwSize;
|
||||||
|
|
||||||
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
|
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
||||||
_T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\DateTime\\Parameters"),
|
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\DateTime\\Parameters",
|
||||||
0,
|
0,
|
||||||
KEY_QUERY_VALUE,
|
KEY_QUERY_VALUE,
|
||||||
&hKey) == ERROR_SUCCESS)
|
&hKey) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
dwSize = 8 * sizeof(TCHAR);
|
dwSize = 8 * sizeof(WCHAR);
|
||||||
if (RegQueryValueEx(hKey,
|
if (RegQueryValueExW(hKey,
|
||||||
_T("Type"),
|
L"Type",
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
(LPBYTE)szData,
|
(LPBYTE)szData,
|
||||||
&dwSize) == ERROR_SUCCESS)
|
&dwSize) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
if (_tcscmp(szData, _T("NTP")) == 0)
|
if (wcscmp(szData, L"NTP") == 0)
|
||||||
SendDlgItemMessage(hwnd, IDC_AUTOSYNC, BM_SETCHECK, 0, 0);
|
SendDlgItemMessageW(hwnd, IDC_AUTOSYNC, BM_SETCHECK, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
RegCloseKey(hKey);
|
RegCloseKey(hKey);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue