title image


Smiley Kann mir bitte jemand diesen Code erklären?
Hallo erstmal,ich habe folgendes Beispiel und ActiveVB.de gesaugt, und kapier es einfach nicht, vielleicht könnte mir jemand von euch helfen, und ihn mir möglichst genau erklären. Wäre echt nett.Option ExplicitPrivate 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 LongPrivate Type FILETIME dwLowDateTime As Long dwHighDateTime As LongEnd TypeConst MAX_PATH = 259Private 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 * 14End TypeConst FILE_ATTRIBUTE_ARCHIVE = &H20Const FILE_ATTRIBUTE_COMPRESSED = &H800Const FILE_ATTRIBUTE_DIRECTORY = &H10Const FILE_ATTRIBUTE_HIDDEN = &H2Const FILE_ATTRIBUTE_NORMAL = &H80Const FILE_ATTRIBUTE_READONLY = &H1Const FILE_ATTRIBUTE_SYSTEM = &H4Const FILE_ATTRIBUTE_TEMPORARY = &H100Private Sub Form_Load() Text1.Text = "C:\Windows\" Text2.Text = "*.*"End SubPrivate Sub Command1_Click() Dim Files() As String, X& Dim DatCnt%, DirCnt% ReDim Files(0 To 0) Call GetAllFiles(Text1.Text, Text2.Text, Files) List1.Clear For X = 0 To UBound(Files) - 1 List1.AddItem Files(X) If Left$(Files(X), 2) = ">>" Then DirCnt = DirCnt + 1 Label5.Caption = DirCnt Label5.Refresh Else DatCnt = DatCnt + 1 Label6.Caption = DatCnt Label6.Refresh End If Next XEnd SubPrivate Sub GetAllFiles(ByVal Root$, ByVal Patt$, ByRef Field$()) Dim File$, hFile&, FD As WIN32_FIND_DATA If Right(Root, 1) "\" Then Root = Root & "\" hFile = FindFirstFile(Root & Patt, FD) If hFile = 0 Then Exit Sub Do File = Left(FD.cFileName, InStr(FD.cFileName, Chr(0)) - 1) If (FD.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY) _ = FILE_ATTRIBUTE_DIRECTORY Then If (File ".") And (File "..") Then 'Verz.: ">>" kann entfernt werden,da nur zur Visualisierung Field(UBound(Field)) = ">>" & Root & File ReDim Preserve Field(0 To UBound(Field) + 1) GetAllFiles Root & File, Patt, Field End If Else 'Datei: " " kann entfernt werden,da nur zur Visualisierung Field(UBound(Field)) = " " & Root & File ReDim Preserve Field(0 To UBound(Field) + 1) End If Loop While FindNextFile(hFile, FD) Call FindClose(hFile)End Sub

geschrieben von

Login

E-Mail:
  

Passwort:
  

Beitrag anfügen

Symbol:
 
 
 
 
 
 
 
 
 
 
 
 
 

Überschrift: