FileTimeToSystemTime?[已解决]
本帖最后由 流沙枫 于 2013-1-16 17:27 编辑#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_UseX64=n
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <Date.au3>
#include <WindowsConstants.au3>
Global $iMemo
_Main()
Func _Main()
Local $tFile, $tSystem,$t
; Create GUI
GUICreate("Time", 400, 300)
$iMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")
GUISetState()
; Encode a file time
For $i=0 To 5
$t = FileGetTime("d:\share\123.txt", 0)
$tFile = _Date_Time_EncodeFileTime($t,$t,$t,$t,$t,$t)
$tSystem = _Date_Time_FileTimeToSystemTime(DllStructGetPtr($tFile))
;MemoWrite("System file time .: " & _Date_Time_SystemTimeToDateTimeStr($tSystem))
MemoWrite("System file time .: " & $t[$i])
Next
; Loop until user exits
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc ;==>_Main
; Write a line to the memo control
Func MemoWrite($sMessage)
GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
EndFunc ;==>MemoWrite
为什么读取文件时间是正确的,转成系统时间后就全是1601/1/1 00:02:00? $tFile = _Date_Time_EncodeSystemTime($t,$t,$t,$t,$t,$t)
;$tSystem = _Date_Time_FileTimeToSystemTime(($tFile))
MemoWrite("System file time .: " & _Date_Time_SystemTimeToDateTimeStr($tFile)) $tFile = _Date_Time_EncodeSystemTime($t,$t,$t,$t,$t,$t)
;$tSystem = _Date_Time_Fi ...
ceoguang 发表于 2013-1-16 16:45 http://www.autoitx.com/images/common/back.gif
全是 00/00/0000 00:00:00了.... #region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_UseX64=n
#endregion ;**** 参数创建于 ACNWrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <Date.au3>
#include <WindowsConstants.au3>
Global $iMemo
_Main()
Func _Main()
Local $tFile, $tSystem, $t
GUICreate("Time", 400, 300)
$iMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")
GUISetState()
$t = FileGetTime("d:\mm.jpg", 0)
$tFile = _Date_Time_EncodeSystemTime($t, $t, $t, $t, $t, $t)
MemoWrite("System file time .: " & _Date_Time_SystemTimeToDateTimeStr($tFile))
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc
Func MemoWrite($sMessage)
GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
EndFunc #region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_UseX64=n
#endregion ;**** 参数创建于...
ceoguang 发表于 2013-1-16 16:53 http://www.autoitx.com/images/common/back.gif
System file time .: 2011/09/0022 13:46:16
多了00? 回复 4# ceoguang
知道问题所在了,原来是数组的问题....
FileGetTime
$array = 年(四位数)
$array = 月(范围是 01 - 12)
$array = 日(范围是 01 - 31)
$array = 时(范围是 00 - 23)
$array = 分(范围是 00 - 59)
$array = 秒(范围是 00 - 59)
注意,返回的数值会被补零(例如20060707).
_Date_Time_EncodeFileTime
$iMonth 月
$iDay 日
$iYear 年
$iHour [可选参数] 时
$iMinute [可选参数] 分
$iSecond [可选参数] 秒
$iMSeconds [可选参数] 毫秒
谢谢版主了....
页:
[1]