I am facing this weird problem where I need to fetch PST timezone information (e.g. MUI_Std, Std, TZI etc.) from Japanese Windows OS machine but unable to find a reliable way to do it.

I have tried RegLoadMUIStringW API. But it returns me name of PST timezone in localized format. I have PST timezone name in English with me. So using output of this API I am not able to compare and tell whether the value being read from registry is for PST timezone.

One possible solution is to have MUI_Std value of PST timezone in code (the value is @tzres.dll,-212) and compare this value with the values read from registry. This way I will come to know if the timezone I am reading is PST or not. But I am not sure if this is a reliable way to detect PST timezone.

Let me know if anyone has any inputs on this.

1

2 Answers

Time zones are identified by their ID (aka "Key Name"), not their localized names. The IDs are not localized.

Thus, regardless of language of the OS, you'll find the Pacific time zone information at:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones\Pacific Standard Time 

Of the values within, only the Std, Dlt, and Display values are localized, and the MUI values point to where those strings are located in the resource files. The resource files are installed with the Windows language packs. Note, you shouldn't hardcoded a value (eg, -212) because a future update might provide a new string that could change it.

Also, if you just need to retrieve the time zone information for a given ID, you don't actually need to access the registry at all. Just use the EnumDynamicTimeZoneInformation function to iterate over the time zones looking for the one that matches the desired TimeZoneKeyName (which again is not localized).

If however, you're looking for the localizations of these in languages other than the current OS language, you could try taking a look at the TimeZoneWindowsResourceExtractor project.

3

I wrote a recent SQL Shack article that shows how to extract time zone / time zone adjustment information directly from a Windows PC registry. The technique shows C# and VB.net desktop apps that build text files with time zone and time zone adjustment information. I placed the code at my GitHub resource, and you can modify it if it does not specifically cover the exact data you need. Mr. Johnson-Pint's earlier content here at SO, and at his blog, really helped me build out my ideas.

HTH!

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.