(V1.1新版本)时间精灵 TimeGhost 下载帖
本帖最后由 alwaystick 于 2016-10-4 12:51 编辑附件(EXE+源码)回复可见。
**** Hidden Message *****
原帖链接:http://www.autoitx.com/thread-53493-1-1.html 下面代码来自本论坛,感觉更简便,可靠.#include-once
#include <Date.au3>
_Timecheck()
Func _Timecheck() ;时间校正
;If Ping('www.baidu.com', 550) Or Ping ('www.163.com') Then
Local $_Now_date, $year, $mon, $mday, $hour, $min, $sec
$_Now_date = _GetSrv_Date()
If @error Then Return SetError(2, '', 0)
$year = StringRegExpReplace($_Now_date, '/.+, '')
$mon = StringRegExpReplace($_Now_date, '.+?/(\d{1,2})/.+', '\1')
$mday = StringRegExpReplace($_Now_date, '.+/(\d{1,2})\D.+', '\1')
$hour = StringRegExpReplace($_Now_date, '.+?(\d{1,2}):.+', '\1')
$min = StringRegExpReplace($_Now_date, '.+?:(\d{1,2}):.+', '\1')
$sec = StringRegExpReplace($_Now_date, '.+:', '')
_SetDate($mday, $mon, $year)
_SetTime($hour, $min, $sec)
ConsoleWrite($year & '\' & $mon & '\' & $mday & ' ' & $hour & ':' & $min & ':' & $sec & @CRLF)
Return 1
;EndIf
;Return SetError(1, '', 0)
EndFunc ;==>_Timecheck
Func _GetSrv_Date()
Local $_Srvlist = ["time-nw.nist.gov", _
"time-a.nist.gov", _
"time-b.nist.gov", _
"time-a.timefreq.bldrdoc.gov", _
"time-b.timefreq.bldrdoc.gov", _
"time-c.timefreq.bldrdoc.gov", _
"utcnist.colorado.edu", _
"time.nist.gov", _
"nist1.datum.com", _
"nist1.dc.glassey.com", _
"nist1.ny.glassey.com", _
"nist1.sj.glassey.com", _
"nist1.aol-ca.truetime.com", _
"nist1.aol-va.truetime.com"]
UDPStartup()
Local $_Time_Srv
For $x = 0 To UBound($_Srvlist) - 1
$_Time_Srv = $_Srvlist[$x]
Local $Socket = UDPOpen(TCPNameToIP($_Time_Srv), 123)
If @error <> 0 Then ContinueLoop
$Status = UDPSend($Socket, MakePacket())
If $Status = 0 Then ContinueLoop
Local $Data = "", $i = 0
While $Data = ""
$i += 1
$Data = UDPRecv($Socket, 100)
If $i = 5 Then ContinueLoop (2)
Sleep(88)
WEnd
UDPCloseSocket($Socket)
UDPShutdown()
ExitLoop
Next
If $Data = "" Then Return SetError(1, '', '')
$Data = UnsignedHexToDec(StringMid($Data, 83, 8))
$Data = _DateTimeFormat(_DateAdd("s", $Data, "1900/01/01 08:00:00"), 0)
Return $Data
EndFunc ;==>_GetSrv_Date
Func MakePacket()
Local $P, $D = "1b0e01000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
While $D
$P &= Chr(Dec(StringLeft($D, 2)))
$D = StringTrimLeft($D, 2)
WEnd
Return $P
EndFunc ;==>MakePacket
Func UnsignedHexToDec($_Data)
Return Dec(StringTrimRight($_Data, 1)) * 16 + Dec(StringRight($_Data, 1))
EndFunc ;==>UnsignedHexToD
看一下,学习一下。win10生效吗? 回复 2# pchome2000
本软件的开发环境就是Win10。 第一次看到的軟件
來學習一下並看看是甚麼功用^^ 本软件的开发环境就是Win10。 {:face (167):}看看 感谢楼主分享,学习了 回复 7# Alam
是NTP协议校时吗?我的软件原理不是NTP协议,是正则提取时间。虽然我的方法的确有点麻烦,不过在有些采用防火墙的网络,能更好地穿透防火墙校时,毕竟一般防火墙不会封锁80端口。 看起来不错的哟 嗯.看起来还不错.. 感谢分享,收藏学习一下。 支持,看看东西 谢谢分享!!!!!!!!!!!! 有什么用呢?系统自身就带这个功能吧?