in src/win32/dt_win32.c [680:730]
static BOOL dt_timezone_read_registry(dt_timezone_t *timezone)
{
HKEY hkey_tz = NULL;
DWORD dwErrorCode = ERROR_RESOURCE_NOT_FOUND;
BOOL returnStatus = FALSE;
char timeZoneName[128] = {0,};
char *keyPath = NULL;
size_t keyPathSize = sizeof(REG_TIME_ZONES) + sizeof(timeZoneName) + sizeof(DYNAMIC_DST) + sizeof('\\') + sizeof('\0');
DWORD dwEnumIndex = 0;
YEARS_ARRAY yearsArray = {0,};
dt_tz_data_t *reg_tz_data = NULL;
WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, timezone->dtzi->TimeZoneKeyName, sizeof(timezone->dtzi->TimeZoneKeyName), timeZoneName, sizeof(timeZoneName), "\0", NULL);
keyPath = malloc(keyPathSize);
snprintf(keyPath, keyPathSize, "%s%s\\%s", REG_TIME_ZONES, timeZoneName, DYNAMIC_DST);
dwErrorCode = RegOpenKeyA(HKEY_LOCAL_MACHINE, keyPath, &hkey_tz);
if (ERROR_SUCCESS != dwErrorCode) {
if (ERROR_FILE_NOT_FOUND != dwErrorCode) {
return FALSE;
} else {
timezone->reg_tz_data_size = 0;
return TRUE;
}
}
if (createYearsArray(hkey_tz, yearsArray) != EXIT_SUCCESS) {
returnStatus = FALSE;
goto GetTimeZoneInformationForYearLower_cleanup;
}
timezone->reg_tz_data_size = yearsArray.count;
timezone->reg_tz_data = malloc(sizeof(dt_tz_data_t) * timezone->reg_tz_data_size);
memset(timezone->reg_tz_data, 0, sizeof(dt_tz_data_t) * timezone->reg_tz_data_size);
reg_tz_data = timezone->reg_tz_data;
for (dwEnumIndex = 0; dwEnumIndex < yearsArray.count && yearsArray.years[dwEnumIndex] != YEAR_WRONG_VALUE; dwEnumIndex++) {
readYearTZDataFromRegistry(keyPath, dwEnumIndex, yearsArray, reg_tz_data);
}
if (yearsArray.size > 0) {
free(yearsArray.years);
}
returnStatus = TRUE;
GetTimeZoneInformationForYearLower_cleanup:
RegCloseKey(hkey_tz);
free(keyPath);
return returnStatus;
}