Foro de elhacker.net

Programación => Programación Visual Basic => Mensaje iniciado por: pungados en 14 Octubre 2007, 14:56 pm



Título: bUSCAR ARCHIVOS
Publicado por: pungados en 14 Octubre 2007, 14:56 pm
Hola gente
Alguno sabe como hacer un buscador de archivos en vb? o si hay un *.OSX que lo haga me lo puede decir?
Muchas gracias.  ;D


Título: Re: bUSCAR ARCHIVOS
Publicado por: ~~ en 14 Octubre 2007, 18:55 pm
No hace falta ningun OCX, con la api SearchTreeForFile lo tienes arreglado, mirate la info del api guide ;)


Título: Re: bUSCAR ARCHIVOS
Publicado por: Surfiction en 19 Octubre 2007, 07:30 am
Espero te sirva...

Código:
Option Explicit On
Module buscar


    Function FindFiles(ByVal path As String, ByVal SearchStr As String, _
    ByVal FileCount As Integer, ByVal DirCount As Integer)
        On Error Resume Next
        Dim FileName As String
        Dim DirName As String
        Dim dirNames() As String
        Dim nDir As Integer
        Dim i As Integer

        On Error GoTo sysFileERR
        If Right(path, 1) <> "\" Then path = path & "\"

        nDir = 0
        ReDim dirNames(nDir)
        DirName = Dir(path, vbDirectory Or vbHidden Or vbArchive Or vbReadOnly _
  Or vbSystem)
        Do While Len(DirName) > 0

            If (DirName <> ".") And (DirName <> "..") Then

                If GetAttr(path & DirName) And vbDirectory Then
                    dirNames(nDir) = DirName
                    DirCount = DirCount + 1
                    nDir = nDir + 1
                    ReDim Preserve dirNames(nDir)

                End If
sysFileERRCont:
            End If
            DirName = Dir()
        Loop


        FileName = Dir(path & SearchStr, vbNormal Or vbHidden Or vbSystem _
        Or vbReadOnly Or vbArchive)
        While Len(FileName) <> 0
            FindFiles = FindFiles + FileLen(path & FileName)
            FileCount = FileCount + 1

'en este caso agrega los resultados en un listview

            inicio.listview1.Items.Add(path & FileName)
           
            FileName = Dir()
        End While


        If nDir > 0 Then

            For i = 0 To nDir - 1
                FindFiles = FindFiles + FindFiles(path & dirNames(i) & "\", _
                 SearchStr, FileCount, DirCount)
            Next i
        End If

AbortFunction:
        Exit Function
sysFileERR:
        If Right(DirName, 4) = ".sys" Then
            Resume sysFileERRCont
        Else
            MsgBox("Error: " & Err.Number & " - " & Err.Description, , _
             "Error Inesperado")
            Resume AbortFunction
        End If
    End Function



End Module