快速全盘文件查找的VB源代码如下,编译用户定义类型未通过,不知道如何修改,请赐教.谢谢

来源:百度知道 编辑:UC知道 时间:2024/06/01 21:59:07
Option Explicit '声明函数
Dim lhwnd As String
Dim dirs, Dir$, files As Integer
Dim isrun As Boolean
Dim WFD As WIN32_FIND_DATA, hItem&, hFile& (错误提示在此)
Private Sub Form_Load()
lhwnd = List1.hWnd
SendMessage lhwnd, LB_INITSTORAGE, 30000&, ByVal 30000& * 200
End Sub
Private Sub Form_Activate() '设定默认路径
Dir1.Path = App.Path
Drive1.Drive = Left(Dir1.Path, 3)
End Sub
Private Sub Dir1_Change() '选择文件夹
Text1.Text = Dir1.Path & "\"
End Sub
Private Sub Drive1_Change() '选择驱动器
Dir1.Path = Drive1.Drive
End Sub
Private Sub SearchDirs(filepath$)
Dim dircount, i As Integer
Dim dirarray()
DoEvents
If Not isrun Then Exit Sub
hItem& = FindFirstFile(filepath$ & "*.*", WFD) '查找文件
If hItem& <> INVALID_HANDLE_VALUE Then
Do
If (WFD.dwFileAttributes And vbDirectory) Then

正确定义应该是这样
'先定义 WIN32_FIND_DATA 类型

Public 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 * MAX_PATH
cAlternate As String * 14
End Type

'定义 WFD 变量为 WIN32_FIND_DATA 类型
Dim WFD As WIN32_FIND_DATA