- /* Note: We get the winid not from static tables but from resource bundle. */
- while (U_SUCCESS(status) && ures_hasNext(bundle)) {
- UBool idFound = FALSE;
- const char* winid;
- UResourceBundle* winTZ = ures_getNextResource(bundle, NULL, &status);
- if (U_FAILURE(status)) {
- break;
+ /*
+ Windows Vista+ provides us with a "TimeZoneKeyName" that is not localized
+ and can be used to directly map a name in our bundle. Try to use that first
+ if we're on Vista or higher
+ */
+ uprv_memset(&osVerInfo, 0, sizeof(osVerInfo));
+ osVerInfo.dwOSVersionInfoSize = sizeof(osVerInfo);
+ GetVersionEx(&osVerInfo);
+ isVistaOrHigher = osVerInfo.dwMajorVersion >= 6; /* actually includes Windows Server 2008 as well, but don't worry about it */
+ tryPreVistaFallback = TRUE;
+ if(isVistaOrHigher) {
+ result = getTZKeyName(regStdName, sizeof(regStdName));
+ if(ERROR_SUCCESS == result) {
+ UResourceBundle* winTZ = ures_getByKey(bundle, regStdName, NULL, &status);
+ if(U_SUCCESS(status)) {
+ const UChar* icuTZ = NULL;
+ if (errorCode != 0) {
+ icuTZ = ures_getStringByKey(winTZ, ISOcodeA, &len, &status);
+ }
+ if (errorCode==0 || icuTZ==NULL) {
+ /* fallback to default "001" and reset status */
+ status = U_ZERO_ERROR;
+ icuTZ = ures_getStringByKey(winTZ, "001", &len, &status);
+ }
+
+ if(U_SUCCESS(status)) {
+ int index=0;
+ while (! (*icuTZ == '\0' || *icuTZ ==' ')) {
+ tmpid[index++]=(char)(*icuTZ++); /* safe to assume 'char' is ASCII compatible on windows */
+ }
+ tmpid[index]='\0';
+ tryPreVistaFallback = FALSE;
+ }
+ }
+ ures_close(winTZ);