我想用VB的文件框列出ie缓存下的*.swf
但ie缓存好像不是文件夹
File1.Parent ="*.swf"
file1.path="C:\Documents and Settings\Administrator\Local Settings\Temporary Internet Files"
结果什么都没发生
如何用VB的文件框或列表框列出ie缓存下的内容
答案:2 悬赏:70 手机版
解决时间 2021-02-05 19:30
- 提问者网友:爱了却不能说
- 2021-02-04 21:04
最佳答案
- 五星知识达人网友:七十二街
- 2021-02-04 22:27
'添加 Command1 Picture1 List1
Private Declare Function FindFirstFile Lib "kernel32" Alias "FindFirstFileA" (ByVal lpFileName As String, lpFindFileData As WIN32_FIND_DATA) As Long
Private Declare Function FindNextFile Lib "kernel32" Alias "FindNextFileA" (ByVal hFindFile As Long, lpFindFileData As WIN32_FIND_DATA) As Long
Private Declare Function FindClose Lib "kernel32" (ByVal hFindFile As Long) As Long
Const INVALID_HANDLE_VALUE = -1
Private Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type
Const MaxLFNPath = 260
Const MAX_PATH = 260
Private Type WIN32_FIND_DATA
dwFileAttributes As Long
ftCreationTime As FILETIME
ftLastAccessTime As FILETIME
ftLastWriteTime As FILETIME
nFileSizeHigh As Long
nFileSizeLow As Long
dwReserved0 As Long
dwReserved1 As Long
cFileName As String * MaxLFNPath
cShortFileName As String * 14
End Type
Dim WFD As WIN32_FIND_DATA
Dim curpath$, schpattern$, hFile&, aa$
Dim addfile As Boolean, tfiles&
Private Sub Form_Load()
curpath = Environ("tmp") & "\"
curpath = "C:\Documents and Settings\Administrator\Internet 临时文件\"
schpattern = "*.swf"
curpath = Replace(curpath, "Temp", "Temporary Internet Files")
End Sub
Private Sub Command1_Click()
tfiles = 0
List1.Clear
Call SearchDirs(curpath$)
MsgBox tfiles
End Sub
Private Sub mohusearch(curpath$)
'On Error Resume Next
If forcestop = False Then
hFile& = FindFirstFile(curpath$ & schpattern, WFD)
If hFile& <> INVALID_HANDLE_VALUE Then
Do
DoEvents
aa = Trim(curpath$) & Trim(WFD.cFileName)
If (WFD.dwFileAttributes And vbDirectory) Or Asc(WFD.cFileName) = 46 Then
Else
addfile = True
If addfile Then
List1.AddItem aa
List1.Selected(List1.ListCount - 1) = True
tfiles = tfiles + 1
End If
End If
Loop While FindNextFile(hFile&, WFD)
Call FindClose(hFile&)
End If
End If
End Sub
Private Sub SearchDirs(curpath$)
'On Error Resume Next
Dim dirs%, dirbuf$(), i%
If forcestop = False Then
Picture1.Cls
Picture1.Print "正在查找 " & curpath$
DoEvents
hItem& = FindFirstFile(curpath$ & "*", WFD)
If hItem& <> INVALID_HANDLE_VALUE Then
Do
DoEvents
If (WFD.dwFileAttributes And vbDirectory) And Asc(WFD.cFileName) <> 46 Then
If (dirs% Mod 10) = 0 Then ReDim Preserve dirbuf$(dirs% + 10)
dirs% = dirs% + 1
dirbuf$(dirs%) = Left$(WFD.cFileName, InStr(WFD.cFileName, vbNullChar) - 1)
End If
Loop While FindNextFile(hItem&, WFD)
Call FindClose(hItem&)
Call mohusearch(curpath$)
End If
For i% = 1 To dirs%
DoEvents
SearchDirs curpath$ & dirbuf$(i%) & "\"
Next i%
End If
End Sub
Private Declare Function FindFirstFile Lib "kernel32" Alias "FindFirstFileA" (ByVal lpFileName As String, lpFindFileData As WIN32_FIND_DATA) As Long
Private Declare Function FindNextFile Lib "kernel32" Alias "FindNextFileA" (ByVal hFindFile As Long, lpFindFileData As WIN32_FIND_DATA) As Long
Private Declare Function FindClose Lib "kernel32" (ByVal hFindFile As Long) As Long
Const INVALID_HANDLE_VALUE = -1
Private Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type
Const MaxLFNPath = 260
Const MAX_PATH = 260
Private Type WIN32_FIND_DATA
dwFileAttributes As Long
ftCreationTime As FILETIME
ftLastAccessTime As FILETIME
ftLastWriteTime As FILETIME
nFileSizeHigh As Long
nFileSizeLow As Long
dwReserved0 As Long
dwReserved1 As Long
cFileName As String * MaxLFNPath
cShortFileName As String * 14
End Type
Dim WFD As WIN32_FIND_DATA
Dim curpath$, schpattern$, hFile&, aa$
Dim addfile As Boolean, tfiles&
Private Sub Form_Load()
curpath = Environ("tmp") & "\"
curpath = "C:\Documents and Settings\Administrator\Internet 临时文件\"
schpattern = "*.swf"
curpath = Replace(curpath, "Temp", "Temporary Internet Files")
End Sub
Private Sub Command1_Click()
tfiles = 0
List1.Clear
Call SearchDirs(curpath$)
MsgBox tfiles
End Sub
Private Sub mohusearch(curpath$)
'On Error Resume Next
If forcestop = False Then
hFile& = FindFirstFile(curpath$ & schpattern, WFD)
If hFile& <> INVALID_HANDLE_VALUE Then
Do
DoEvents
aa = Trim(curpath$) & Trim(WFD.cFileName)
If (WFD.dwFileAttributes And vbDirectory) Or Asc(WFD.cFileName) = 46 Then
Else
addfile = True
If addfile Then
List1.AddItem aa
List1.Selected(List1.ListCount - 1) = True
tfiles = tfiles + 1
End If
End If
Loop While FindNextFile(hFile&, WFD)
Call FindClose(hFile&)
End If
End If
End Sub
Private Sub SearchDirs(curpath$)
'On Error Resume Next
Dim dirs%, dirbuf$(), i%
If forcestop = False Then
Picture1.Cls
Picture1.Print "正在查找 " & curpath$
DoEvents
hItem& = FindFirstFile(curpath$ & "*", WFD)
If hItem& <> INVALID_HANDLE_VALUE Then
Do
DoEvents
If (WFD.dwFileAttributes And vbDirectory) And Asc(WFD.cFileName) <> 46 Then
If (dirs% Mod 10) = 0 Then ReDim Preserve dirbuf$(dirs% + 10)
dirs% = dirs% + 1
dirbuf$(dirs%) = Left$(WFD.cFileName, InStr(WFD.cFileName, vbNullChar) - 1)
End If
Loop While FindNextFile(hItem&, WFD)
Call FindClose(hItem&)
Call mohusearch(curpath$)
End If
For i% = 1 To dirs%
DoEvents
SearchDirs curpath$ & dirbuf$(i%) & "\"
Next i%
End If
End Sub
全部回答
- 1楼网友:酒安江南
- 2021-02-04 23:33
额
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯