PDA

View Full Version : Obtaining user's time zone information...


Superbank
06-11-2009, 06:14 AM
It's a pity that System.GetTime is not returning time zone information in addition to current system time...

How to obtain user's time zone information?

Probably we can use Kernel32.dll and GetTimeZoneInformation function?

Something like:

DLLResult = DLL.CallFunction("Kernel32.dll", "GetTimeZoneInformation", "TZI", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);


Please correct me if I am wrong...

pww
06-11-2009, 07:19 AM
if you need the GMT offset, it's available in the registry

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Contro l\TimeZoneInformation\

Read ActiveTimeBias (current offset with DST taken into account) or Bias (offset with DST excluded)

Offset is in minutes, so something like 0xFFFFFF88 is -2 hours