Solved

Change system time zone

Posted on 2004-04-20
3
1,444 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 50 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

705 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