|
发表于 2008-5-26 03:07:45
|
显示全部楼层
[au3]$x=SetLocalTime(17,20,0,2007,10,15)
MsgBox(0,"",$x)
Func SetLocalTime($Hour, $Min, $Sec =0,$Year = 0,$Month = 0,$Day = 0)
Local $Error = 0
Local $Return = False
If $Hour < 0 Or $Hour > 23 Then $Error = 1
If $Min < 0 Or $Min > 59 Then $Error = 1
If $Sec < 0 Or $Sec > 59 Then $Error = 1
If @NumParams > 3 And ($Day < 1 Or $Day > 31) Then $Error = 1
If @NumParams > 4 And ($Month < 1 Or $Month > 12) Then $Error = 1
If @NumParams > 5 And ($Year < 1601 Or $Year > 30827) Then $Error = 1
If Not $Error Then
Local $Struct = DLLStructCreate('Short;Short;Short;Short;Short;Short;Short;Short')
Local $StructPtr = DLLStructGetPtr($Struct)
If @NumParams < 6 Then
DLLCall('Kernel32', 'None', 'GetLocalTime', 'Ptr', $StructPtr)
If @Error Then $Error = 2
EndIf
If Not $Error Then
DLLStructSetData($Struct, 5, $Hour)
DLLStructSetData($Struct, 6, $Min)
DLLStructSetData($Struct, 7, $Sec)
DLLStructSetData($Struct, 8, 0)
If @NumParams > 3 Then DLLStructSetData($Struct, 4, $Day)
If @NumParams > 4 Then DLLStructSetData($Struct, 2, $Month)
If @NumParams > 5 Then DLLStructSetData($Struct, 1, $Year)
DLLCall('Kernel32', 'None', 'SetLocalTime', 'Ptr', $StructPtr)
Local $Result = DLLCall('Kernel32', 'Int', 'SetLocalTime', 'Ptr', $StructPtr)
If @Error Then
$Error = 2
Else
$Return = ($Result[0] <> 0)
EndIf
EndIf
EndIf
SetError($Error)
Return $Return
EndFunc[/au3] |
|