3 * Copyright (C) 2004, 2005 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * PROJECT: ReactOS International Control Panel
22 * FILE: lib/cpl/intl/locale.c
23 * PURPOSE: Locale property page
24 * PROGRAMMER: Eric Kohl
37 // * change registry function (-> "HKCR\MIME\Database\Rfc1766")
41 typedef struct _TZ_INFO
46 SYSTEMTIME StandardDate
;
47 SYSTEMTIME DaylightDate
;
50 typedef struct _TIMEZONE_ENTRY
52 struct _TIMEZONE_ENTRY
*Prev
;
53 struct _TIMEZONE_ENTRY
*Next
;
54 WCHAR Description
[64]; /* 'Display' */
55 WCHAR StandardName
[32]; /* 'Std' */
56 WCHAR DaylightName
[32]; /* 'Dlt' */
57 TZ_INFO TimezoneInfo
; /* 'TZI' */
58 ULONG Index
; /* 'Index' */
59 } TIMEZONE_ENTRY
, *PTIMEZONE_ENTRY
;
63 PTIMEZONE_ENTRY TimeZoneListHead
= NULL
;
64 PTIMEZONE_ENTRY TimeZoneListTail
= NULL
;
69 static PTIMEZONE_ENTRY
70 GetLargerTimeZoneEntry(DWORD Index
)
72 PTIMEZONE_ENTRY Entry
;
74 Entry
= TimeZoneListHead
;
77 if (Entry
->Index
>= Index
)
88 CreateTimeZoneList(VOID
)
99 PTIMEZONE_ENTRY Entry
;
100 PTIMEZONE_ENTRY Current
;
104 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
105 L
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones",
115 lError
= RegEnumKeyExW(hZonesKey
,
123 if (lError
!= ERROR_SUCCESS
&& lError
!= ERROR_MORE_DATA
)
127 if (RegOpenKeyExW(hZonesKey
,
135 Entry
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(TIMEZONE_ENTRY
));
138 RegCloseKey(hZonesKey
);
142 dwValueSize
= 64 * sizeof(WCHAR
);
143 if (RegQueryValueExW(hZonesKey
,
147 (LPBYTE
)&Entry
->Description
,
150 RegCloseKey(hZonesKey
);
154 dwValueSize
= 32 * sizeof(WCHAR
);
155 if (RegQueryValueExW(hZonesKey
,
159 (LPBYTE
)&Entry
->StandardName
,
162 RegCloseKey(hZonesKey
);
166 dwValueSize
= 32 * sizeof(WCHAR
);
167 if (RegQueryValueExW(hZonesKey
,
171 (LPBYTE
)&Entry
->DaylightName
,
174 RegCloseKey(hZonesKey
);
178 dwValueSize
= sizeof(DWORD
);
179 if (RegQueryValueExW(hZonesKey
,
183 (LPBYTE
)&Entry
->Index
,
186 RegCloseKey(hZonesKey
);
190 dwValueSize
= sizeof(TZ_INFO
);
191 if (RegQueryValueExW(hZonesKey
,
195 (LPBYTE
)&Entry
->TimezoneInfo
,
198 RegCloseKey(hZonesKey
);
202 RegCloseKey(hZoneKey
);
204 if (TimeZoneListHead
== NULL
&&
205 TimeZoneListTail
== NULL
)
209 TimeZoneListHead
= Entry
;
210 TimeZoneListTail
= Entry
;
214 Current
= GetLargerTimeZoneEntry(Entry
->Index
);
217 if (Current
== TimeZoneListHead
)
219 /* Prepend to head */
221 Entry
->Next
= TimeZoneListHead
;
222 TimeZoneListHead
->Prev
= Entry
;
223 TimeZoneListHead
= Entry
;
227 /* Insert before current */
228 Entry
->Prev
= Current
->Prev
;
229 Entry
->Next
= Current
;
230 Current
->Prev
->Next
= Entry
;
231 Current
->Prev
= Entry
;
237 Entry
->Prev
= TimeZoneListTail
;
239 TimeZoneListTail
->Next
= Entry
;
240 TimeZoneListTail
= Entry
;
247 RegCloseKey(hZonesKey
);
253 ShowTimeZoneList(HWND hwnd
)
255 TIME_ZONE_INFORMATION TimeZoneInfo
;
256 PTIMEZONE_ENTRY Entry
;
260 GetTimeZoneInformation(&TimeZoneInfo
);
264 Entry
= TimeZoneListHead
;
265 while (Entry
!= NULL
)
270 (LPARAM
)Entry
->Description
);
272 if (!wcscmp(Entry
->StandardName
, TimeZoneInfo
.StandardName
))
288 /* Property page dialog callback */
290 LocalePageProc(HWND hwndDlg
,
299 CreateTimeZoneList();
300 ShowTimeZoneList(GetDlgItem(hwndDlg
, IDC_LANGUAGELIST
));