如何编写代码用国家授时中心服务器对本地电脑进行时间校准
如题
[解决办法]
void __fastcall TForm1::Button1Click(TObject *Sender)
{
//indy里的TidTime
IdTime1->Host = "129.6.15.28";
ShowMessage(DateTimeToStr(IdTime1->DateTime));
}
//---------------------------------------
IdSNTP1->Host = "210.72.145.44";
IdSNTP1->ReceiveTimeout = 3000;
bool bSuccess = IdSNTP1->SyncTime();
ShowMessage(String().sprintf("较时%s", bSuccess? "成功": "失败"));