返回一个使用全球协调时(UTC)表示的当前系统时间
#Include <Date.au3>
_Date_Time_GetSystemTime()
#include <GUIConstantsEx.au3>
#include <Date.au3>
#include <WindowsConstants.au3>
; 由于系统安全性在 Vista 中 Windows API "SetSystemTime" 可能被拒绝
Global $iMemo
_Main()
Func _Main()
Local $tCur, $tNew
; 创建 GUI
GUICreate("Time", 400, 300)
$iMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")
GUISetState()
; 获取当前系统时间
$tCur = _Date_Time_GetSystemTime()
MemoWrite("Current system date/time .: " & _Date_Time_SystemTimeToDateTimeStr($tCur))
; 设置新的系统时间
$tNew = _Date_Time_EncodeSystemTime(8, 19, @YEAR, 3, 10, 45)
If Not _Date_Time_SetSystemTime(DllStructGetPtr($tNew)) Then
MsgBox(4096, "错误", "System clock cannot be SET" & @CRLF & @CRLF & _WinAPI_GetLastErrorMessage())
Exit
EndIf
$tNew = _Date_Time_GetSystemTime()
MemoWrite("New system date/time .....: " & _Date_Time_SystemTimeToDateTimeStr($tNew))
; 恢复系统时间
_Date_Time_SetSystemTime(DllStructGetPtr($tCur))
; 获取当前系统时间
$tCur = _Date_Time_GetSystemTime()
MemoWrite("Current system date/time .: " & _Date_Time_SystemTimeToDateTimeStr($tCur))
; 循环直到用户退出
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc ;==>_Main
; 写入一行到 memo 控件
Func MemoWrite($sMessage)
GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
EndFunc ;==>MemoWrite