Delphi源码分享网络服务器时间授时中心时间校对
unit NetTime;
interface
uses
Windows, SysUtils, IdSNTP, IdStack;
function GetNetTime: TDateTime;
implementation
function GetNetTime: TDateTime;
var
IdSNTP: TIdSNTP;
begin
IdSNTP := TIdSNTP.Create(nil);
try
IdSNTP.Host := 'ntp.aliyun.com'; // 阿里云公网NTP服务器
IdSNTP.Port := IdSNTP.StandardNTPPort;
IdSNTP.Active := True;
Result := IdSNTP.DateTime;
finally
IdSNTP.Free;
end;
end;
end.
下载地址
用户评论