按钮SET点击事件处理程序如下:
var
MyST:TsystemTime;
begin
  with MyST do
  begin
    wYear:=   StrToInt(LabeledEdit1.Text);
    wMonth:=  StrToInt(LabeledEdit2.Text);
    wDay:=    StrToInt(LabeledEdit3.Text);
    wHour:=   StrToInt(LabeledEdit4.Text);
    wMinute:= StrToInt(LabeledEdit5.Text);
    wSecond:= StrToInt(LabeledEdit6.Text);
  end;
  SetSystemTime(MyST);
end;
使用时,系统时间可以被更新。但是每次被更新过的时间中,小时总是要比输入的数值多8。必须把小时的赋值语句替换为
    wHour:=   StrToInt(LabeledEdit4.Text)-8;
才能按照输入的数值更改系统时间。请问这是为什么?

解决方案 »

  1.   

    你可能是将系统的时区弄错了,中国在东8时区,比格林尼治时间早8小时。SetSystemTime和GetSystemTime是以格林尼治时间为基准,用GetLocalTime可以取到本地时间,SetLocalTime可以设置本地时间。在Windows.pas 中,说明如下:
    procedure GetLocalTime(var lpSystemTime: TSystemTime); stdcall;
    function SetLocalTime(const lpSystemTime: TSystemTime): BOOL; stdcall;注意,你的计算机设置的“区域”应该是“中国”。
      

  2.   

    呵呵,学习一下, Seahilly(小峰) 说的很清楚了