home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / fileve1a / idd_main.frm (.txt) < prev   
Encoding:
Visual Basic Form  |  1999-09-23  |  7.3 KB  |  206 lines

  1. VERSION 5.00
  2. Begin VB.Form IDD_Main 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "File Logger"
  5.    ClientHeight    =   3660
  6.    ClientLeft      =   45
  7.    ClientTop       =   330
  8.    ClientWidth     =   4020
  9.    Icon            =   "IDD_Main.frx":0000
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    ScaleHeight     =   3660
  14.    ScaleWidth      =   4020
  15.    StartUpPosition =   2  'CenterScreen
  16.    Begin VB.CheckBox IDCK_StaggerOutput 
  17.       Caption         =   "Stagger Output"
  18.       Height          =   255
  19.       Left            =   2040
  20.       TabIndex        =   7
  21.       Top             =   2520
  22.       Value           =   1  'Checked
  23.       Width           =   1935
  24.    End
  25.    Begin VB.TextBox IDE_SearchString 
  26.       Height          =   285
  27.       Left            =   120
  28.       TabIndex        =   5
  29.       Text            =   "*.*"
  30.       Top             =   2760
  31.       Width           =   1695
  32.    End
  33.    Begin VB.CommandButton IDCM_Exit 
  34.       Caption         =   "E&xit"
  35.       Height          =   375
  36.       Left            =   2640
  37.       TabIndex        =   4
  38.       Top             =   3120
  39.       Width           =   1215
  40.    End
  41.    Begin VB.CommandButton IDCM_Execute 
  42.       Caption         =   "&Execute"
  43.       Default         =   -1  'True
  44.       Height          =   375
  45.       Left            =   120
  46.       TabIndex        =   3
  47.       Top             =   3120
  48.       Width           =   1215
  49.    End
  50.    Begin VB.CheckBox IDCK_Recursive 
  51.       Caption         =   "Recurse Directories"
  52.       Height          =   255
  53.       Left            =   2040
  54.       TabIndex        =   2
  55.       Top             =   2760
  56.       Value           =   1  'Checked
  57.       Width           =   1935
  58.    End
  59.    Begin VB.DirListBox IDDIR_Local 
  60.       Height          =   1890
  61.       Left            =   120
  62.       TabIndex        =   1
  63.       Top             =   120
  64.       Width           =   3735
  65.    End
  66.    Begin VB.DriveListBox IDDRIVE_Local 
  67.       Height          =   315
  68.       Left            =   120
  69.       TabIndex        =   0
  70.       Top             =   2160
  71.       Width           =   3735
  72.    End
  73.    Begin VB.Label IDL_SearchString 
  74.       AutoSize        =   -1  'True
  75.       Caption         =   "Search String"
  76.       Height          =   195
  77.       Left            =   120
  78.       TabIndex        =   6
  79.       Top             =   2520
  80.       Width           =   960
  81.    End
  82. Attribute VB_Name = "IDD_Main"
  83. Attribute VB_GlobalNameSpace = False
  84. Attribute VB_Creatable = False
  85. Attribute VB_PredeclaredId = True
  86. Attribute VB_Exposed = False
  87. Option Explicit
  88. Dim LevelsDeep As Integer
  89. Private Sub Form_Load()
  90.     LevelsDeep = 0
  91. End Sub
  92. Private Sub IDCM_Execute_Click()
  93. Dim LocalPath As String
  94. Dim LogFileName As String
  95. Dim PrintString As String
  96. Dim FileCount As Integer
  97. Dim DirCount As Integer
  98.     Me.MousePointer = vbHourglass
  99.     If Right(IDDIR_Local.path, 1) = "\" Then
  100.         LocalPath = IDDIR_Local.path
  101.     Else
  102.         LocalPath = IDDIR_Local.path & "\"
  103.     End If
  104.     LogFileName = Environ("TEMP") & "\" & App.Title & ".log"
  105.     Open LogFileName For Output As #1
  106.     PrintString = "File Log for Directory: " & Mid(LocalPath, 1, Len(LocalPath) - 1)
  107.     If IDCK_Recursive.Value = vbChecked Then
  108.         PrintString = PrintString & " (Recursing Sub Directories)"
  109.     End If
  110.     Print #1, PrintString
  111.     Print #1, Now
  112.     Print #1,
  113.     Call FindFiles(LocalPath, IDE_SearchString, FileCount, DirCount, CInt(IDCK_Recursive.Value) * -1)
  114.     Close #1
  115.     Call Shell("notepad " & LogFileName, vbMaximizedFocus)
  116.     Me.MousePointer = vbDefault
  117. End Sub
  118. Function FindFiles(path As String, SearchStr As String, FileCount As Integer, DirCount As Integer, Optional ByVal RecurseSubs As Boolean = True)
  119. Dim FileInformation As FILE_INFORMATION
  120. Dim FileName As String   ' Walking filename variable.
  121. Dim DirName As String    ' SubDirectory Name.
  122. Dim dirNames() As String ' Buffer for directory name entries.
  123. Dim nDir As Integer      ' Number of directories in this path.
  124. Dim i As Integer         ' For-loop counter.
  125. Dim VersionInfo As String
  126. Dim LastDir As String
  127. Dim Spaces As String
  128. Dim Count As Integer
  129. Const SpaceChar As String = vbTab
  130.     On Error GoTo sysFileERR
  131.     If Right(path, 1) <> "\" Then path = path & "\"
  132.     ' Search for subdirectories.
  133.     nDir = 0
  134.     ReDim dirNames(nDir)
  135.     DirName = Dir(path, vbDirectory Or vbHidden)  ' Even if hidden.
  136.     Do While Len(DirName) > 0
  137.         ' Ignore the current and encompassing directories.
  138.         If (DirName <> ".") And (DirName <> "..") Then
  139.             ' Check for directory with bitwise comparison.
  140.             If GetAttr(path & DirName) And vbDirectory Then
  141.                dirNames(nDir) = DirName
  142.                DirCount = DirCount + 1
  143.                nDir = nDir + 1
  144.                ReDim Preserve dirNames(nDir)
  145.             End If
  146. sysFileERRCont:
  147.         End If
  148.         DirName = Dir()  ' Get next subdirectory.
  149.     Loop
  150.     ' Search through this directory and sum file sizes.
  151.     FileName = Dir(path & SearchStr, vbNormal Or vbHidden Or vbSystem Or vbReadOnly)
  152.     While Len(FileName) <> 0
  153.         FindFiles = FindFiles + FileLen(path & FileName)
  154.         FileCount = FileCount + 1
  155.         Call GetFileInformation(path & FileName, FileInformation)
  156.         Spaces = ""
  157.         If IDCK_StaggerOutput.Value = vbChecked Then
  158.             If LevelsDeep > 0 Then
  159.                 For Count = 1 To LevelsDeep
  160.                     Spaces = Spaces & SpaceChar
  161.                 Next Count
  162.             End If
  163.         Else
  164.             Spaces = ""
  165.         End If
  166.         If FileInformation.cDirectory <> LastDir Then
  167.             Print #1,
  168.             Print #1, Spaces & "Directory: --> " & FileInformation.cDirectory
  169.             Print #1, Spaces & "-----------------------------------------------------------------------"
  170.             LastDir = FileInformation.cDirectory
  171.         End If
  172.         If FileInformation.nVerMajor <> 0 Or FileInformation.nVerMinor <> 0 Or FileInformation.nVerRevision <> 0 Then
  173.             VersionInfo = " - Version:" & FileInformation.nVerMajor & "." & FileInformation.nVerMinor & "." & FileInformation.nVerRevision
  174.         Else
  175.             VersionInfo = ""
  176.         End If
  177. '        Spaces = Spaces & SpaceChar
  178.         Print #1, Spaces & FileInformation.cFilename & " - Modify Date:" & Format(FileInformation.dtLastModifyTime, "mm/dd/yyyy HH:MM AMPM") & " - File Size:" & FileInformation.nFileSize & " bytes" & VersionInfo
  179.         FileName = Dir()  ' Get next file.
  180.     Wend
  181.     ' If there are sub-directories..
  182.     If nDir > 0 And RecurseSubs = True Then
  183.         ' Recursively walk into them
  184.         For i = 0 To nDir - 1
  185.             LevelsDeep = LevelsDeep + 1
  186.             FindFiles = FindFiles + FindFiles(path & dirNames(i) & "\", SearchStr, FileCount, DirCount)
  187.             LevelsDeep = LevelsDeep - 1
  188.         Next i
  189.     End If
  190. AbortFunction:
  191.     Exit Function
  192. sysFileERR:
  193.     If Right(DirName, 4) = ".sys" Then
  194.         Resume sysFileERRCont ' Known issue with pagefile.sys
  195.     Else
  196.         Resume AbortFunction
  197.     End If
  198. End Function
  199. Private Sub IDCM_Exit_Click()
  200.     Unload Me
  201. End Sub
  202. Private Sub IDDRIVE_Local_Change()
  203.     On Error Resume Next
  204.     IDDIR_Local.path = IDDRIVE_Local.Drive
  205. End Sub
  206.