VFP實現網路校時

2021-04-30 07:52:21 字數 1110 閱讀 6565

vfp實現網路校時

*客戶機與校時伺服器日期相同時可以校對時間,日期有差異時校時會失敗

=strtofile

("@net time /setsntp:210.72.145.44"+

chr(13)+

chr(10)+"@net stop w32time"+

chr(13)+

chr(10)+"@net start w32time"+

chr(13)+

chr(10)+"@w32tm /resync /rediscover","mytempbat.bat")

declare long

winexec

in kernel32

string

,long

=winexec("mytempbat.bat",0)

注:但是使用 net time

或 w32time 來校時有乙個問題值得我們注意,當客戶機與校時伺服器 日期 有差異的時候,校時會失敗。

如果要避免這個問題以及進一步實現網路精確對時,也可以編寫網路通訊程式,由專門的伺服器、客戶端通訊程式來實現網路對時。

生成的批處理檔案內容為(---線之間內容)

--------------------------------

@net time

/setsntp:210.72.145.44

@net stop w32time

@net start w32time

@w32tm /resync /rediscover

--------------------------------

註解:@net time

,這裡用 210.72.145.44 ,這是中國國家授時中心的sntp伺服器

@net stop w32time:關閉w32time校時服務

@net start w32time:重啟w32time服務來實現網路校時

@w32tm /resync /rediscover:windows xp手動校準時間(如果是windows 2000:w32tm -s),/resync:告訴計算機它應該盡快同步它的時鐘,丟棄所有積累的錯誤。/rediscover:重新檢測網路配置並重新發現網路資源,然後重新同步。

網路自動校時器

if strtotime 06 01 01 strtotime timetostr time then 呼叫 begin timer1.enabled false verifystandardtime 校驗標準時間 timer1.enabled true end procedure tmyservi...

網路校時(非NTP)

windows一用就是幾年,總會碰到個更改系統時間的時候。可是把系統時間調壞了容易,要調出個正確可就沒那麼簡單了。幾年前 還上大學的時候,大概是大三吧 用c 寫過乙個ntp的程式,但是時過境遷,ntp的ip更改實在太頻繁了 難道是因為沒有商業利潤?windows的 internet 時間 我從來就沒...

在電腦上開啟網路校時服務

在電腦上開啟網路校時服務的方法 1 通過開始選單,輸入regedit命令後開啟登錄檔設定畫面,此時請一定備份登錄檔檔案。2 修改以下選項的鍵值 hkey local machine system currentcontrolset services w32time timeproviders ntp...