|
楼主 |
发表于 2012-8-25 23:53:43
|
显示全部楼层
回复 2# yunnl
在请教一下 下面的代码中 我的代码要添加到哪里
#include <Date.au3>
$_End_date = "2012-12-21";结束日期
$_Now_date = _GetSrv_Date()
$_End_Splt = StringSplit($_End_date, "-")
$_Now_Splt = StringSplit($_Now_date, "-")
$_sDate_End = _Date_Time_EncodeFileTime($_End_Splt[2], $_End_Splt[3], $_End_Splt[1])
$_sDate_Now = _Date_Time_EncodeFileTime($_Now_Splt[2], $_Now_Splt[3], $_Now_Splt[1])
$_Compare = _Date_Time_CompareFileTime(DllStructGetPtr($_sDate_End), DllStructGetPtr($_sDate_Now))
If $_Compare = -1 Then
MsgBox(0, "", "世界末日 已经结束,谢谢支持!")
ElseIf $_Compare = 0 Then
MsgBox(0, "", "你很荣幸正在经历 世界末日!")
Else
$DateCalc = _DateDiff('d', $_Now_date, $_End_date)
MsgBox(0, "", "世界末日 将发生于 " & $_End_date & " (" & $DateCalc & "天) 后!")
EndIf
Exit
Func _GetSrv_Date()
Local $_Srvlist[14] = ["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 0
$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 ;==>UnsignedHexToDec |
|