mirror of
https://github.com/reactos/reactos.git
synced 2025-08-04 19:26:29 +00:00
[TIMEDATE]
Fixes and improvements to datetime CPL applet. Patch by Carlo Bramini. Replaced the original RegLocalQuery() by QueryTimezoneData() to simplify the error handling. Modification by Eric Kohl. CORE-11284 #resolve #comment Thanks a lot! svn path=/trunk/; revision=71433
This commit is contained in:
parent
be0e0e64a7
commit
345ad196e3
1 changed files with 74 additions and 75 deletions
|
@ -24,11 +24,10 @@ typedef struct _TIMEZONE_ENTRY
|
||||||
{
|
{
|
||||||
struct _TIMEZONE_ENTRY *Prev;
|
struct _TIMEZONE_ENTRY *Prev;
|
||||||
struct _TIMEZONE_ENTRY *Next;
|
struct _TIMEZONE_ENTRY *Next;
|
||||||
WCHAR Description[64]; /* 'Display' */
|
WCHAR Description[128]; /* 'Display' */
|
||||||
WCHAR StandardName[33]; /* 'Std' */
|
WCHAR StandardName[33]; /* 'Std' */
|
||||||
WCHAR DaylightName[33]; /* 'Dlt' */
|
WCHAR DaylightName[33]; /* 'Dlt' */
|
||||||
TZ_INFO TimezoneInfo; /* 'TZI' */
|
TZ_INFO TimezoneInfo; /* 'TZI' */
|
||||||
ULONG Index; /* 'Index ' */
|
|
||||||
} TIMEZONE_ENTRY, *PTIMEZONE_ENTRY;
|
} TIMEZONE_ENTRY, *PTIMEZONE_ENTRY;
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,17 +37,26 @@ static int cxSource, cySource;
|
||||||
PTIMEZONE_ENTRY TimeZoneListHead = NULL;
|
PTIMEZONE_ENTRY TimeZoneListHead = NULL;
|
||||||
PTIMEZONE_ENTRY TimeZoneListTail = NULL;
|
PTIMEZONE_ENTRY TimeZoneListTail = NULL;
|
||||||
|
|
||||||
static PTIMEZONE_ENTRY
|
static
|
||||||
GetLargerTimeZoneEntry(DWORD Index)
|
PTIMEZONE_ENTRY
|
||||||
|
GetLargerTimeZoneEntry(
|
||||||
|
LONG Bias,
|
||||||
|
LPWSTR lpDescription)
|
||||||
{
|
{
|
||||||
PTIMEZONE_ENTRY Entry;
|
PTIMEZONE_ENTRY Entry;
|
||||||
|
|
||||||
Entry = TimeZoneListHead;
|
Entry = TimeZoneListHead;
|
||||||
while (Entry != NULL)
|
while (Entry != NULL)
|
||||||
{
|
{
|
||||||
if (Entry->Index >= Index)
|
if (Entry->TimezoneInfo.Bias > Bias)
|
||||||
return Entry;
|
return Entry;
|
||||||
|
|
||||||
|
if (Entry->TimezoneInfo.Bias == Bias)
|
||||||
|
{
|
||||||
|
if (_wcsicmp(Entry->Description, lpDescription) > 0)
|
||||||
|
return Entry;
|
||||||
|
}
|
||||||
|
|
||||||
Entry = Entry->Next;
|
Entry = Entry->Next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,17 +64,65 @@ GetLargerTimeZoneEntry(DWORD Index)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static
|
||||||
|
LONG
|
||||||
|
QueryTimezoneData(
|
||||||
|
HKEY hZoneKey,
|
||||||
|
PTIMEZONE_ENTRY Entry)
|
||||||
|
{
|
||||||
|
DWORD dwValueSize;
|
||||||
|
LONG lError;
|
||||||
|
|
||||||
|
dwValueSize = 128 * sizeof(WCHAR);
|
||||||
|
lError = RegQueryValueExW(hZoneKey,
|
||||||
|
L"Display",
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
(LPBYTE)&Entry->Description,
|
||||||
|
&dwValueSize);
|
||||||
|
if (lError != ERROR_SUCCESS)
|
||||||
|
return lError;
|
||||||
|
|
||||||
|
dwValueSize = 33 * sizeof(WCHAR);
|
||||||
|
lError = RegQueryValueExW(hZoneKey,
|
||||||
|
L"Std",
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
(LPBYTE)&Entry->StandardName,
|
||||||
|
&dwValueSize);
|
||||||
|
if (lError != ERROR_SUCCESS)
|
||||||
|
return lError;
|
||||||
|
|
||||||
|
dwValueSize = 33 * sizeof(WCHAR);
|
||||||
|
lError = RegQueryValueExW(hZoneKey,
|
||||||
|
L"Dlt",
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
(LPBYTE)&Entry->DaylightName,
|
||||||
|
&dwValueSize);
|
||||||
|
if (lError != ERROR_SUCCESS)
|
||||||
|
return lError;
|
||||||
|
|
||||||
|
dwValueSize = sizeof(TZ_INFO);
|
||||||
|
lError = RegQueryValueExW(hZoneKey,
|
||||||
|
L"TZI",
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
(LPBYTE)&Entry->TimezoneInfo,
|
||||||
|
&dwValueSize);
|
||||||
|
return lError;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static VOID
|
static VOID
|
||||||
CreateTimeZoneList(VOID)
|
CreateTimeZoneList(VOID)
|
||||||
{
|
{
|
||||||
WCHAR szKeyName[256];
|
WCHAR szKeyName[256];
|
||||||
DWORD dwIndex;
|
DWORD dwIndex;
|
||||||
DWORD dwNameSize;
|
DWORD dwNameSize;
|
||||||
DWORD dwValueSize;
|
|
||||||
LONG lError;
|
LONG lError;
|
||||||
HKEY hZonesKey;
|
HKEY hZonesKey;
|
||||||
HKEY hZoneKey;
|
HKEY hZoneKey;
|
||||||
|
|
||||||
PTIMEZONE_ENTRY Entry;
|
PTIMEZONE_ENTRY Entry;
|
||||||
PTIMEZONE_ENTRY Current;
|
PTIMEZONE_ENTRY Current;
|
||||||
|
|
||||||
|
@ -77,10 +133,9 @@ CreateTimeZoneList(VOID)
|
||||||
&hZonesKey))
|
&hZonesKey))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dwIndex = 0;
|
for (dwIndex = 0; ; dwIndex++)
|
||||||
while (TRUE)
|
|
||||||
{
|
{
|
||||||
dwNameSize = 256 * sizeof(WCHAR);
|
dwNameSize = sizeof(szKeyName);
|
||||||
lError = RegEnumKeyExW(hZonesKey,
|
lError = RegEnumKeyExW(hZonesKey,
|
||||||
dwIndex,
|
dwIndex,
|
||||||
szKeyName,
|
szKeyName,
|
||||||
|
@ -106,71 +161,17 @@ CreateTimeZoneList(VOID)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
dwValueSize = 64 * sizeof(WCHAR);
|
lError = QueryTimezoneData(hZoneKey,
|
||||||
lError = RegQueryValueExW(hZoneKey,
|
Entry);
|
||||||
L"Display",
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
(LPBYTE)&Entry->Description,
|
|
||||||
&dwValueSize);
|
|
||||||
if (lError != ERROR_SUCCESS)
|
|
||||||
{
|
|
||||||
RegCloseKey(hZoneKey);
|
|
||||||
dwIndex++;
|
|
||||||
HeapFree(GetProcessHeap(), 0, Entry);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
dwValueSize = 33 * sizeof(WCHAR);
|
|
||||||
if (RegQueryValueExW(hZoneKey,
|
|
||||||
L"Std",
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
(LPBYTE)&Entry->StandardName,
|
|
||||||
&dwValueSize))
|
|
||||||
{
|
|
||||||
RegCloseKey(hZoneKey);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
dwValueSize = 33 * sizeof(WCHAR);
|
|
||||||
if (RegQueryValueExW(hZoneKey,
|
|
||||||
L"Dlt",
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
(LPBYTE)&Entry->DaylightName,
|
|
||||||
&dwValueSize))
|
|
||||||
{
|
|
||||||
RegCloseKey(hZoneKey);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
dwValueSize = sizeof(DWORD);
|
|
||||||
if (RegQueryValueExW(hZoneKey,
|
|
||||||
L"Index",
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
(LPBYTE)&Entry->Index,
|
|
||||||
&dwValueSize))
|
|
||||||
{
|
|
||||||
RegCloseKey(hZoneKey);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
dwValueSize = sizeof(TZ_INFO);
|
|
||||||
if (RegQueryValueExW(hZoneKey,
|
|
||||||
L"TZI",
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
(LPBYTE)&Entry->TimezoneInfo,
|
|
||||||
&dwValueSize))
|
|
||||||
{
|
|
||||||
RegCloseKey(hZoneKey);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
RegCloseKey(hZoneKey);
|
RegCloseKey(hZoneKey);
|
||||||
|
|
||||||
|
if (lError != ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
HeapFree(GetProcessHeap(), 0, Entry);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (TimeZoneListHead == NULL &&
|
if (TimeZoneListHead == NULL &&
|
||||||
TimeZoneListTail == NULL)
|
TimeZoneListTail == NULL)
|
||||||
{
|
{
|
||||||
|
@ -181,7 +182,7 @@ CreateTimeZoneList(VOID)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Current = GetLargerTimeZoneEntry(Entry->Index);
|
Current = GetLargerTimeZoneEntry(Entry->TimezoneInfo.Bias, Entry->Description);
|
||||||
if (Current != NULL)
|
if (Current != NULL)
|
||||||
{
|
{
|
||||||
if (Current == TimeZoneListHead)
|
if (Current == TimeZoneListHead)
|
||||||
|
@ -210,8 +211,6 @@ CreateTimeZoneList(VOID)
|
||||||
TimeZoneListTail = Entry;
|
TimeZoneListTail = Entry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dwIndex++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RegCloseKey(hZonesKey);
|
RegCloseKey(hZonesKey);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue