Solved

Change system time zone

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

856 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