Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Change system time zone

Posted on 2004-04-20
3
Medium Priority
?
1,489 Views
Last Modified: 2008-02-01
Hi experts,

Is there any EASY way to change Windows' time zone through the registry?  I found the registry key with the time zone information...
"HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation"
but it doesn't seem to be easy to manipulate, because of all the names, etc... that also need to be set when changing the time zone (not only the bias).

Is it easier to use the SetTimeZoneInformation WinAPI call to change the system's time zone?  Can anyone give me some sample code on how to change the date, time, and time zone using this function?

Thanks,
dannyguindi
0
Comment
Question by:dannyguindi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 17

Accepted Solution

by:
mokule earned 200 total points
ID: 10873003
Hi
Look there
http://17slon.com/gp/gp/gptimezone.htm
and there
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/settimezoneinformation.asp

and here how You can use the function

var
  tz: _TIME_ZONE_INFORMATION;
begin

GetTimeZoneInformation(tz); // to check current settings

// UTC = local time + bias + standard bias
// or
// UTC = local time + bias + daylight bias

tz.Bias := -60;

FillChar(tz.StandardName,sizeof(tz.StandardName),#0);
// can set any string
StringToWideChar('Standard Time',tz.StandardName,sizeof(tz.StandardName));
tz.StandardDate.wYear := 0;
tz.StandardDate.wMonth := 10;    // October
tz.StandardDate.wDayOfWeek := 0; // sunday
tz.StandardDate.wDay := 5;      // means last week of month
tz.StandardDate.wHour := 3;
tz.StandardDate.wMinute := 0;
tz.StandardDate.wSecond := 0;
tz.StandardDate.wMilliseconds := 0;
tz.StandardBias := 0;

FillChar(tz.DaylightName,sizeof(tz.DaylightName),#0);
StringToWideChar('Summer Time',tz.DaylightName,sizeof(tz.DaylightName));
tz.DaylightDate.wYear := 0;
tz.DaylightDate.wMonth := 3;     // March
tz.DaylightDate.wDayOfWeek := 0; // sunday
tz.DaylightDate.wDay := 5;      // last week of month
tz.DaylightDate.wHour := 2;
tz.DaylightDate.wMinute := 0;
tz.DaylightDate.wSecond := 0;
tz.DaylightDate.wMilliseconds := 0;
tz.DaylightBias := -60;

SetTimeZoneInformation(tz);
0
 

Author Comment

by:dannyguindi
ID: 10893818
Just what I needed.  Many thanks.
0
 
LVL 17

Expert Comment

by:mokule
ID: 10894041
I'm happy to help :)

Marek
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question