以前曾在网上看到一段话:当AU3运用得已经非常熟练,以为是编程高手的时候,却不知道API函数TerminateProcess 是做什么用的。 现在这情况真相似啊。
Func _FileGetTime($sFilePath, $iTime = 1, $fText = 1)
Local Const $tagFILETIME = "dword LowDateTime;dword HighDateTime"
Local Const $tagSYSTEMTIME = "word Year;word Month;word DayofWeek;word Day;word Hour;word Minute;word Second;word Milliseconds"
Local $hFile = DllCall("Kernel32.dll", "handle", "CreateFileW", "wstr", $sFilePath, "dword", 0x80000000, "dword", 3, "dword", 0, "dword", 3, "dword", 0, "handle", 0)
$hFile = $hFile[0]
If ($hFile < 1) Then Return SetError(1, 0, "")
Local $tCreationTime, $tLastAccessTime, $tLastWriteTime
Switch $iTime
Case 1
$tCreationTime = DllStructCreate($tagFILETIME)
Case 2
$tLastAccessTime = DllStructCreate($tagFILETIME)
Case Else
$iTime = 3
$tLastWriteTime = DllStructCreate($tagFILETIME)
EndSwitch
Local $iResult
$iResult = DllCall("Kernel32.dll", "bool", "GetFileTime", _
"handle", $hFile, _
"ptr", DllStructGetPtr($tCreationTime), _
"ptr", DllStructGetPtr($tLastAccessTime), _
"ptr", DllStructGetPtr($tLastWriteTime))
DllCall("Kernel32.dll", "bool", "CloseHandle", "handle", $hFile)
If ($iResult[0] = 0) Then Return SetError(1, 0, "")
Local $tFileTime = DllStructCreate($tagFILETIME)
Local $pFileTime = DllStructGetPtr($tFileTime)
Local $tSysTime = DllStructCreate($tagSYSTEMTIME)
Local $pSysTime = DllStructGetPtr($tSysTime)
DllCall("Kernel32.dll", "bool", "FileTimeToLocalFileTime", "ptr", $iResult[$iTime + 1], "ptr", $pFileTime)
DllCall("Kernel32.dll", "bool", "FileTimeToSystemTime", "ptr", $pFileTime, "ptr", $pSysTime)
Local $aResult[7]
$aResult[0] = DllStructGetData($tSysTime, "Year")
$aResult[1] = DllStructGetData($tSysTime, "Month")
$aResult[2] = DllStructGetData($tSysTime, "Day")
$aResult[3] = DllStructGetData($tSysTime, "Hour")
$aResult[4] = DllStructGetData($tSysTime, "Minute")
$aResult[5] = DllStructGetData($tSysTime, "Second")
$aResult[6] = DllStructGetData($tSysTime, "Milliseconds")
If $fText Then
Return StringFormat("%04d/%02d/%02d %02d:%02d:%02d.%03d", $aResult[0], $aResult[1], $aResult[2], $aResult[3], $aResult[4], $aResult[5], $aResult[6])
Else
Return $aResult
EndIf
EndFunc ;==>_FileGetTime
|