找回密码
 加入
搜索
查看: 4249|回复: 5

[系统综合] FileTimeToSystemTime?[已解决]

  [复制链接]
发表于 2013-1-16 16:27:27 | 显示全部楼层 |阅读模式
本帖最后由 流沙枫 于 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[0],$t[1],$t[2],$t[3],$t[4],$t[5])
        $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?
发表于 2013-1-16 16:45:44 | 显示全部楼层
$tFile = _Date_Time_EncodeSystemTime($t[0],$t[1],$t[2],$t[3],$t[4],$t[5])
;$tSystem = _Date_Time_FileTimeToSystemTime(($tFile))
MemoWrite("System file time .: " & _Date_Time_SystemTimeToDateTimeStr($tFile))
 楼主| 发表于 2013-1-16 16:49:19 | 显示全部楼层
$tFile = _Date_Time_EncodeSystemTime($t[0],$t[1],$t[2],$t[3],$t[4],$t[5])
;$tSystem = _Date_Time_Fi ...
ceoguang 发表于 2013-1-16 16:45



全是    00/00/0000 00:00:00了....
发表于 2013-1-16 16:53:37 | 显示全部楼层
#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[0], $t[1], $t[2], $t[3], $t[4], $t[5])
        MemoWrite("System file time .: " & _Date_Time_SystemTimeToDateTimeStr($tFile))
        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE

EndFunc

Func MemoWrite($sMessage)
        GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
EndFunc
 楼主| 发表于 2013-1-16 17:11:11 | 显示全部楼层
#region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_UseX64=n
#endregion ;**** 参数创建于  ...
ceoguang 发表于 2013-1-16 16:53



    System file time .: 2011/09/0022 13:46:16

多了00?
 楼主| 发表于 2013-1-16 17:14:37 | 显示全部楼层
回复 4# ceoguang


    知道问题所在了,原来是数组的问题....
FileGetTime

$array[0] = 年(四位数)
$array[1] = 月(范围是 01 - 12)
$array[2] = 日(范围是 01 - 31)
$array[3] = 时(范围是 00 - 23)
$array[4] = 分(范围是 00 - 59)
$array[5] = 秒(范围是 00 - 59)
注意,返回的数值会被补零(例如20060707).

_Date_Time_EncodeFileTime

$iMonth 月
$iDay 日
$iYear 年
$iHour [可选参数] 时
$iMinute [可选参数] 分
$iSecond [可选参数] 秒
$iMSeconds [可选参数] 毫秒

谢谢版主了....
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-20 15:23 , Processed in 0.081721 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表