home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form Form1
- Caption = "Form1"
- ClientHeight = 5760
- ClientLeft = 60
- ClientTop = 345
- ClientWidth = 8175
- LinkTopic = "Form1"
- ScaleHeight = 5760
- ScaleWidth = 8175
- StartUpPosition = 3 'Windows Default
- Begin VB.TextBox Text1
- BeginProperty Font
- Name = "Lucida Console"
- Size = 14.25
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 4935
- Left = 1440
- MultiLine = -1 'True
- ScrollBars = 2 'Vertical
- TabIndex = 1
- Top = 240
- Width = 6615
- End
- Begin VB.CommandButton Command1
- Caption = "Directory"
- Height = 495
- Left = 120
- TabIndex = 0
- Top = 240
- Width = 1215
- End
- Attribute VB_Name = "Form1"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Option Explicit
- Const MAX_PATH = 260
- Const INVALID_HANDLE = -1
- Private Type FILETIME
- dwLowDateTime As Long
- dwHighDateTime As Long
- End Type
- 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
- 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 * MAX_PATH
- cAlternate As String * 14
- End Type
- Dim fd As WIN32_FIND_DATA
- Function FindFiles(currentPath As String) As NodeList
- Dim h As Long, more As Boolean
- Dim n As NodeList, list As NodeList, fn As String, attr As Integer
- Set list = New NodeList
- h = FindFirstFile(currentPath & "\*.*", fd)
- more = h <> INVALID_HANDLE
- While more
- fn = TrimString(fd.cFileName)
- If Left(fn, 1) <> "." Then
- attr = fd.dwFileAttributes
- If attr And vbDirectory Then
- Set n = FindFiles(currentPath & "\" & fn)
- Else
- Set n = Nothing
- End If
- Call list.Add(fn, attr, n)
- End If
- more = FindNextFile(h, fd)
- Set FindFiles = list
- FindClose (h)
- End Function
- Private Sub Command1_Click()
- Dim tree As NodeList
- Set tree = FindFiles("C:\")
- Text1.Text = tree.Display("")
- End Sub
- Function TrimString(s1 As String) As String
- Dim i As Long
- i = InStr(s1, Chr(0))
- TrimString = Left(s1, i - 1)
- End Function
-