請教一個能使客戶机与服務器時間同步問題???(50分)

  • 主题发起人 冒险家
  • 开始时间

冒险家

Unregistered / Unconfirmed
GUEST, unregistred user!
各位好:
    我想請教一個問題。如何确保客戶机時間与服務器時間同步。在DELPHI中如何實現。謝謝各位!
 
弄个时间服务程序放在服务器上就是了
indy -> idtime intimeserver
 
可有語句。直接更改客戶机時間嗎?
 
用IDTIME的方法:
var temptime:string;
begin
try
IdTime1.Host:='ftz-mis-5';
temptime:=formatdatetime('yyyy-mm-dd hh:mm',IdTime1.DateTime);
form1.caption:=datetimetostr(IdTime1.DateTime);
except
end;
end;

另外还可以直接调用NET TIME
 
这个啊。还需要这么复杂吗。搞个ntp服务器一切ok
 
我的意思是:更改客戶机系統時間。。可有語句實現
 
用IDTIME的方法:
var temptime:string;
begin
try
IdTime1.Host:='ftz-mis-5';
temptime:=formatdatetime('yyyy-mm-dd hh:mm',IdTime1.DateTime);
form1.caption:=datetimetostr(IdTime1.DateTime);
DecodeDate(date_time,t.wYear,t.wMonth,t.wDay);
DecodeTime(date_time+0.6/ (24*3600),t.wHour,t.wMinute,t.wSecond,t.wMilliseconds);
SetLocalTime(t);

except
end;
end;
-------------------------
NET TIME的方法不用多说了吧。
c:/wINDOWS/system32/net time //ftz-mis-5 /set /y
 
procedure TServiceFrm.Button1Click(Sender: TObject);
var
date_time: TDateTime;
t: _SYSTEMTIME;
begin
With AdoQuery1do
begin
Close;
SQL.Clear;
SQL.Add('select sysdate from dual');
Open;
Date_Time := Fields[0].AsDateTime;
end;

DecodeDate(date_time,t.wYear,t.wMonth,t.wDay);
DecodeTime(Date_time,t.wHour,t.wMinute,t.wSecond,t.wMilliseconds);
SetLocalTime(t);
end;

問題解決: 感謝各位的回帖。
 
多人接受答案了。
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
728
import
I
S
回复
0
查看
819
SUNSTONE的Delphi笔记
S
顶部