I use WinAPI to set the time zone in a Windows XP SP3 window. I read the time zone information from the key HKLM\Software\Microsoft\WindowsNT\Time Zones\<time zone name>, and then set the time zone to the specified time zone.
I list the keys under the Time Zones key, grab the value TZIand add it to the structure TIME_ZONE_INFORMATIONthat will be passed to SetTimeZoneInformation . Everything seems to work on the first pass. Changing the time zone, the error is not returned.
The second time I perform this operation (the same user, new session, when logging in to the user), the call is successful, but the system does not reflect the change in time zone. Neither the clock nor the timestamps for files are updated in the new time zone. When I go to:
HKLM\System\CurrentControlSet\Control\TimeZoneInformationthere is new information about the time zone.
A few strange things happen when I set my time zone:
- Also, when I parse the TZI binary value from the registry for storage in my structure
TIME_ZONE_INFORMATION, I notice that the structure has a field DaylightDate.wDayand StandardDate.wDayalways set to 0 - I tried calling GetTimeZoneInformation right after the call
SetTimeZoneInformation, but the call ended with error 1300. (Not all privileges or groups to which the link is made are assigned to the caller.)
I will also send a message WM_BROADCASTto let Explorer know what is going on.
Think parsing a byte array into a structure TIME_ZONE_INFORMATION? Or did I miss something else important?
EDIT:
I found a document that says why this happens: here . The privilege was implemented in Vista ... thanks to MSDN documents ...
Microsoft SE_TIME_ZONE_NAME
. LookupPriviledgeValue
SE_TIME_ZONE_NAME 1313 ( .).