找回密码
 加入
搜索
查看: 1055|回复: 1

如何获得临时文件的所有属性

[复制链接]
发表于 2009-5-6 16:19:30 | 显示全部楼层 |阅读模式
Temporary Internet Files文件夹下的文件。将该文件夹视图设为【详细信息】,便可以知道了题目的要求。现在,要获得除名称以外的属性,如何做呢?
发表于 2009-5-6 18:57:45 | 显示全部楼层
#include <Date.au3>

Const $tagCache = "dword;ptr[2];dword[5];dword[2];dword[2];dword[2];dword[2];ptr;dword;ptr"

Dim $hFind = _FindFirstUrlCacheEntry()

FileWrite("TempFile.txt", "TempInternetFiles" & @CRLF)


While True
        $aCache = _FindNextUrlCacheEntry($hFind)
        If @error Then ExitLoop
        For $o = 0 to Ubound($aCache) - 1
                FileWrite("TempFile.txt", $aCache[$o] & @CRLF)
        Next
        FileWrite("TempFile.txt", @CRLF)
WEnd

ShellExecute("TempFile.txt")

Func _FindFirstUrlCacheEntry()
        Local $tCache, $pCache, $hFind

        $hFind = DllCall("Wininet.dll", "hWnd", "FindFirstUrlCacheEntry", _
                        "str", "", "ptr", 0, "int*", 0)
        $tCache = DllStructCreate("ubyte[" & $hFind[3] & "]")
        $pCache = DllStructGetPtr($tCache)

        $hFind = DllCall("Wininet.dll", "hWnd", "FindFirstUrlCacheEntry", _
                        "str", "", "ptr", $pCache, "int*", $hFind[3])
        $tCache = 0
        Return $hFind[0]
EndFunc        ;==>_FindFirstUrlCacheEntry()


Func _FindNextUrlCacheEntry(ByRef $hFind)
        Local $tBuffer, $pBuffer, $iSizeofBuffer, $tCache, $iResult

        $iResult = DllCall("Wininet.dll", "int", "FindNextUrlCacheEntry", _
                        "hWnd", $hFind, "ptr", 0, "int*", 0)

        $iSizeofBuffer = $iResult[3]
        $tBuffer = DllStructCreate("ubyte[" & $iSizeofBuffer & "]")
        $pBuffer = DllStructGetPtr($tBuffer)

        $iResult = DllCall("Wininet.dll", "int", "FindNextUrlCacheEntry", _
                        "hWnd", $hFind, "ptr", $pBuffer, "int*", $iSizeofBuffer)

        If Not $iResult[0] Then Return SetError(259, 0, 0)
        Local $tCache, $tSrcUrl, $tLocalFile, $aResult[10], $sFileExt

        $tCache = DllStructCreate($tagCache, $pBuffer)
        $tSrcUrl = DllStructCreate("char[512]", DllStructGetData($tCache, 2, 1))
        $tLocalFile = DllStructCreate("char[512]", DllStructGetData($tCache, 2, 2))

        $aResult[0] = DllStructGetData($tLocalFile, 1)
        $aResult[1] = DllStructGetData($tSrcUrl, 1)
        $sFileExt = StringRegExp($aResult[0], "\.([^\.]+$)", 3)
        If IsArray($sFileExt) Then
                $aResult[2] = $sFileExt[0] & " File"
        Else
                $aResult[2] = "Unknown File"
        EndIf
        $aResult[3] = DllStructGetData($tCache, 3, 1)
        $aResult[4] = DllStructGetData($tCache, 3, 2)
        $aResult[5] = DllStructGetData($tCache, 3, 3)
        $aResult[6] = _FormatTime(DllStructGetPtr($tCache, 4))
        $aResult[7] = _FormatTime(DllStructGetPtr($tCache, 5))
        $aResult[8] = _FormatTime(DllStructGetPtr($tCache, 6))
        $aResult[9] = _FormatTime(DllStructGetPtr($tCache, 7))

        $tBuffer = 0
        $tCache = 0
        $tSrcURL = 0
        $tFileExt = 0
        $tLocalFile = 0
        Return SetError(Not $iResult[0], 0, $aResult)
EndFunc        ;==>_FindNextUrlCacheEntry()


Func _FormatTime($pTime)
        Local $tSysTime

        $tSysTime = _Date_Time_FileTimeToSystemTime($pTime)
        Return _Date_Time_SystemTimeToDateTimeStr($tSysTime)
EndFunc        ;==>_FormatTime()

评分

参与人数 1金钱 +5 贡献 +5 收起 理由
jiataifeng + 5 + 5

查看全部评分

您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-12-25 10:16 , Processed in 0.078592 second(s), 28 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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