elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Sigue las noticias más importantes de seguridad informática en el Twitter! de elhacker.NET


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP)
| | | |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo)
| | | | |-+  [Source CLS] Cls_Files (Multi-Criterio)
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: [Source CLS] Cls_Files (Multi-Criterio)  (Leído 3,186 veces)
BlackZeroX
Wiki

Desconectado Desconectado

Mensajes: 3.158


I'Love...!¡.


Ver Perfil WWW
[Source CLS] Cls_Files (Multi-Criterio)
« en: 11 Octubre 2010, 19:38 pm »

.
Código
  1.  
  2. '
  3. '   /////////////////////////////////////////////////////////////
  4. '   // Autor:   BlackZeroX ( Ortega Avila Miguel Angel )       //
  5. '   //                                                         //
  6. '   // Web:     http://InfrAngeluX.Sytes.Net/                  //
  7. '   //                                                         //
  8. '   //    |-> Pueden Distribuir Este codigo siempre y cuando   //
  9. '   // no se eliminen los creditos originales de este codigo   //
  10. '   // No importando que sea modificado/editado o engrandecido //
  11. '   // o achicado, si es en base a este codigo                 //
  12. '   /////////////////////////////////////////////////////////////
  13.  
  14. Option Explicit
  15.  
  16. Private Declare Function lstrcmp Lib "kernel32" Alias "lstrcmpA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
  17. Private Declare Function FindFirstFile& Lib "kernel32" Alias "FindFirstFileA" (ByVal lpFileName$, lpFindFileData As WIN32_FIND_DATA)
  18. Private Declare Function FindNextFile& Lib "kernel32" Alias "FindNextFileA" (ByVal hFindFile&, lpFindFileData As WIN32_FIND_DATA)
  19. Private Declare Function GetFileAttributes Lib "kernel32" Alias "GetFileAttributesA" (ByVal lpFileName As String) As Long
  20. Private Declare Function FindClose& Lib "kernel32" (ByVal hFindFile&)
  21.  
  22. Const MAX_PATH                              As Integer = 260
  23. Const MAXDWORD                              As Long = &HFFFF
  24. Const INVALID_HANDLE_VALUE                  As Long = -1
  25.  
  26. Private Type FILETIME
  27.    dwLowDateTime                           As Long
  28.    dwHighDateTime                          As Long
  29. End Type
  30.  
  31. Private Type WIN32_FIND_DATA
  32.    dwFileAttributes                        As Long
  33.    ftCreationTime                          As FILETIME
  34.    ftLastAccessTime                        As FILETIME
  35.    ftLastWriteTime                         As FILETIME
  36.    nFileSizeHigh                           As Long
  37.    nFileSizeLow                            As Long
  38.    dwReserved0                             As Long
  39.    dwReserved1                             As Long
  40.    cFileName                               As String * MAX_PATH
  41.    cAlternate                              As String * 14
  42. End Type
  43.  
  44. Event Folder(ByRef PathFolder As String, ByVal Atrributes As VbFileAttribute)
  45. Event File(ByRef NameFile As String, ByRef TypeOfFile As Long, ByVal Atrributes As VbFileAttribute)
  46. Event Begin()
  47. Event Finish()
  48.  
  49. Private Priv_StrDir$, Priv_StrCri$(), Priv_IncFolder As Boolean, Priv_Cancel As Boolean
  50. Private Priv_CriFindInDir As VbFileAttribute, Priv_CriFindInFile  As VbFileAttribute
  51. Private Hwnd_SearchF&(), LS_Index&(0 To 1), BytesNow_#
  52. Private Bool_Run As Byte
  53.  
  54. Public AllowEvents                          As Boolean
  55.  
  56. Private Sub Class_Initialize()
  57.    Priv_IncFolder = True
  58.    AllowEvents = True
  59.    Priv_CriFindInDir = vbDirectory
  60.    Priv_CriFindInFile = vbArchive
  61. End Sub
  62.  
  63. Public Property Get BytesNow#()
  64.    BytesNow# = BytesNow_#
  65. End Property
  66.  
  67. Public Property Get FindInPath() As String
  68.    FindInPath = Priv_StrDir$
  69. End Property
  70.  
  71. Public Property Let FindInPath(ByVal vData$)
  72.    Call Stop_
  73.    Call NormalizePath&(vData$)
  74.    Priv_StrDir$ = vData$
  75. End Property
  76.  
  77.  
  78.  
  79. Public Property Get CriterionFindDir() As VbFileAttribute
  80.    CriterionFindDir = Priv_CriFindInDir
  81. End Property
  82. Public Property Let CriterionFindDir(ByVal vData As VbFileAttribute)
  83.    Call Stop_
  84.    Priv_CriFindInDir = vData Or vbDirectory
  85. End Property
  86.  
  87. Public Property Get CriterionFindFile() As VbFileAttribute
  88.    CriterionFindFile = Priv_CriFindInFile
  89. End Property
  90. Public Property Let CriterionFindFile(ByVal vData As VbFileAttribute)
  91.    Call Stop_
  92.    Priv_CriFindInFile = vData Or vbArchive
  93. End Property
  94.  
  95.  
  96.  
  97. Public Property Get CriterionToFind() As Variant
  98.    CriterionToFind = Priv_StrCri$
  99. End Property
  100.  
  101. Public Property Let CriterionToFind(ByRef vData As Variant)
  102. On Error GoTo Err_
  103. Dim L_Index                             As Long
  104.    Call Stop_
  105.    Erase Priv_StrCri$
  106.    LS_Index&(0) = INVALID_HANDLE_VALUE
  107.    LS_Index&(1) = INVALID_HANDLE_VALUE
  108.    If IsArray(vData) Then
  109.        LS_Index&(0) = LBound(vData)
  110.        LS_Index&(1) = UBound(vData)
  111.        ReDim Priv_StrCri$(LS_Index&(0) To LS_Index&(1))
  112.        For L_Index = LS_Index&(0) To LS_Index&(1)
  113.            Priv_StrCri$(L_Index) = CStr(vData(L_Index))
  114.        Next L_Index
  115.    Else
  116.        LS_Index&(0) = 0
  117.        LS_Index&(1) = 0
  118.        ReDim Priv_StrCri$(0)
  119.        Priv_StrCri$(0) = vData
  120.    End If
  121. Exit Property
  122. Err_:
  123.    Err.Clear
  124. End Property
  125.  
  126. Public Property Get IncludeSubFolders() As Boolean: IncludeSubFolders = Priv_IncFolder: End Property
  127. Public Property Let IncludeSubFolders(ByVal vData As Boolean): Priv_IncFolder = vData: End Property
  128.  
  129. Public Property Get ItsRun() As Boolean:    ItsRun = Bool_Run = 1:      End Property
  130.  
  131. Public Sub Stop_():    Bool_Run = 0: Priv_Cancel = True: End Sub
  132.  
  133. Public Function Start_(Optional StrFindInPath As Variant = "", Optional StrCriterionToFind As Variant = Nothing) As Double
  134.  
  135.    Call Stop_
  136.    BytesNow_# = 0
  137.    If Not StrFindInPath = "" Then FindInPath = StrFindInPath
  138.    If Not IsObject(StrCriterionToFind) Then CriterionToFind = StrCriterionToFind
  139.    If Not (LS_Index&(0) = INVALID_HANDLE_VALUE And LS_Index&(0) = INVALID_HANDLE_VALUE) And Priv_StrDir$ <> "" And CStr(Dir(Priv_StrDir$, vbDirectory)) <> "" Then
  140.        RaiseEvent Begin
  141.        Bool_Run = 1
  142.        Priv_Cancel = False
  143.        Call FindFilesAPI#(Priv_StrDir$, Priv_StrCri$())
  144.        Start_# = BytesNow_#
  145.        Bool_Run = 0
  146.        RaiseEvent Finish
  147.    End If
  148.  
  149. End Function
  150.  
  151. Private Sub FindFilesAPI(ByVal StrPath$, ByRef StrSearch$())
  152. Dim str_NameNow$
  153. Dim Str_NameDir$()
  154. Dim Lng_DirCant&
  155. Dim Lng_DirCount&
  156. Dim LF_Index&
  157. 'Dim Lng_Res&
  158. Dim Hwnd_Search&
  159. Dim WFD                                 As WIN32_FIND_DATA
  160.  
  161.    Lng_DirCount& = 0
  162.    Hwnd_Search& = FindFirstFile&(StrPath$ & "*", WFD)
  163.  
  164.    If Hwnd_Search& <> INVALID_HANDLE_VALUE Then
  165.        RaiseEvent Folder(StrPath$, WFD.dwFileAttributes)
  166.        Do
  167.            If AllowEvents Then DoEvents
  168.            If Priv_Cancel Then Exit Sub
  169.            With WFD
  170.                str_NameNow$ = Left$(.cFileName, InStr(.cFileName, Chr(0)) - 1)
  171.                If (((.dwFileAttributes Or Priv_CriFindInDir) = .dwFileAttributes) And ((.dwFileAttributes And vbDirectory) = vbDirectory)) Then
  172.                    If (str_NameNow$ <> ".") And (str_NameNow$ <> "..") Then
  173.                        ReDim Preserve Str_NameDir$(Lng_DirCount&)
  174.                        Str_NameDir$(Lng_DirCount&) = str_NameNow$
  175.                        Lng_DirCount& = Lng_DirCount& + 1
  176.                    End If
  177.                End If
  178.            End With
  179.        Loop While FindNextFile&(Hwnd_Search&, WFD)
  180.  
  181.        Call FindClose(Hwnd_Search&)
  182.  
  183.        For LF_Index& = LS_Index&(0) To LS_Index&(1)
  184.            Hwnd_Search& = FindFirstFile&(StrPath$ & StrSearch$(LF_Index&), WFD)
  185.            If Hwnd_Search& <> INVALID_HANDLE_VALUE Then
  186.                Do
  187.                    If AllowEvents Then DoEvents
  188.                    If Priv_Cancel Then Exit Sub
  189.                    With WFD
  190.                        str_NameNow$ = Left$(.cFileName, InStr(.cFileName, Chr(0)) - 1)
  191.                        If (((.dwFileAttributes Or Priv_CriFindInFile) = .dwFileAttributes) And ((.dwFileAttributes And vbArchive) = vbArchive)) Then
  192.  
  193.                            If (str_NameNow$ <> ".") And (str_NameNow$ <> "..") Then
  194.                                BytesNow_# = BytesNow_# + ((.nFileSizeHigh& * MAXDWORD&) + .nFileSizeLow&) + 0
  195.                                RaiseEvent File(str_NameNow$, LF_Index&, .dwFileAttributes)
  196.                            End If
  197.                        End If
  198.                    End With
  199.                Loop While FindNextFile&(Hwnd_Search&, WFD)
  200.                Call FindClose(Hwnd_Search&)
  201.            End If
  202.        Next LF_Index
  203.  
  204.        If Lng_DirCount& > 0 And Priv_IncFolder Then
  205.            For Lng_DirCant& = 0 To Lng_DirCount& - 1
  206.                Call FindFilesAPI#(StrPath$ & Str_NameDir$(Lng_DirCant&) & "\", StrSearch$)
  207.            Next
  208.        End If
  209.  
  210.    End If
  211.  
  212. End Sub
  213.  
  214. '   Returns
  215. '   //  0   =   NoPathValid
  216. '   //  1   =   Ok
  217. '   //  2   =   Fixed/Ok
  218. Public Function NormalizePath&(ByRef sData$)
  219.  
  220.    If Strings.Len(sData$) > 1 Then
  221.        sData$ = Strings.Replace(sData$, "/", "\")
  222.        If Not Strings.Right$(sData$, 1) = "\" Then
  223.            sData$ = sData$ & "\"
  224.            NormalizePath& = 2
  225.        Else
  226.            NormalizePath& = 1
  227.        End If
  228.    Else
  229.        NormalizePath& = 0
  230.    End If
  231.  
  232. End Function
  233.  
  234.  

Modo de declaración...

Código
  1.  
  2. Private WithEvents ClsScanDisk          As Cls_Files
  3.  
  4. ' // Proceso X
  5.    If ClsScanDisk Is Nothing Then Set ClsScanDisk = New Cls_Files
  6.    With ClsScanDisk
  7.        If .ItsRun Then Call .Stop_
  8.        .CriterionToFind = Split("*.mp3,*.wma,*.mid,*.midi", ",")
  9.        '   //  ó tambien...
  10.        .CriterionToFind = "*.mp3"
  11.        .FindInPath = "c:\"
  12.        Call .Start_
  13.    End With
  14. ' // Fin Proceso X
  15.  
  16.  

Eventos:

Código
  1.  
  2. Event Folder(ByRef PathFolder As String, ByVal Atrributes As VbFileAttribute)
  3. Event File(ByRef NameFile As String, ByRef TypeOfFile As Long, ByVal Atrributes As VbFileAttribute)
  4. Event Begin()
  5. Event Finish()
  6.  
  7.  

Código
  1.  
  2. Option Explicit
  3.  
  4. Private WithEvents ClsScanDisk          As cls_files
  5. Private ThisPath$
  6. Private CountFiles&
  7.  
  8. Private Sub ClsScanDisk_Begin()
  9.    ThisPath$ = ClsScanDisk.FindInPath
  10.    CountFiles& = 0
  11.    Caption = "ScanDisk ha Encontrado: "
  12. End Sub
  13.  
  14. Private Sub ClsScanDisk_File(NameFile As String, TypeOfFile As Long, ByVal Atrributes As Long)
  15.    CountFiles& = CountFiles& + 1
  16.    Caption = "ScanDisk ha Encontrado: " & CountFiles&
  17.    Debug.Print ThisPath$ & NameFile
  18.    Debug.Print vbTab & "Criterio:"; ClsScanDisk.CriterionToFind(TypeOfFile),
  19.    Debug.Print "Atributos:"; Atrributes
  20. End Sub
  21.  
  22. Private Sub ClsScanDisk_Finish()
  23.    Caption = "ScanDisk ha Encontrado: " & CountFiles& & " -> Finalizado."
  24. End Sub
  25.  
  26. Private Sub ClsScanDisk_Folder(PathFolder As String, ByVal Atrributes As Long)
  27.    ThisPath$ = PathFolder
  28. End Sub
  29.  
  30.  
  31. Private Sub Form_Load()
  32.    If ClsScanDisk Is Nothing Then Set ClsScanDisk = New cls_files
  33.    With ClsScanDisk
  34.        If .ItsRun Then .Stop_
  35.        .CriterionToFind = Split("*.mp3,*.wma,*.avi,*.mid,*.mid", ",")
  36.        '.CriterionFindDir = vbReadOnly                  '   //  Solo directorios de Solo lectura.
  37.        '.CriterionFindFile = vbHidden Or vbReadOnly     '  //  Solo archivos ocultos.
  38.        .FindInPath = "c:\"
  39.        .AllowEvents = True
  40.        Call .Start_
  41.    End With
  42. End Sub
  43.  
  44.  

Dulce Infierno Lunar!¡.


« Última modificación: 14 Octubre 2010, 07:53 am por BlackZeroX▓▓▒▒░░ » En línea

The Dark Shadow is my passion.
Psyke1
Wiki

Desconectado Desconectado

Mensajes: 1.089



Ver Perfil WWW
Re: [Source CLS] Cls_Files (Multi-Criterio)
« Respuesta #1 en: 11 Octubre 2010, 22:54 pm »

Wow! :O
Despues lo pruebo y te comento! ;)
¿haces la competencia a L.A.? >:D :laugh:

DoEvents! :P


En línea

BlackZeroX
Wiki

Desconectado Desconectado

Mensajes: 3.158


I'Love...!¡.


Ver Perfil WWW
Re: [Source CLS] Cls_Files (Multi-Criterio)
« Respuesta #2 en: 12 Octubre 2010, 04:00 am »

Wow! :O
Despues lo pruebo y te comento! ;)
¿haces la competencia a L.A.? >:D :laugh:

DoEvents! :P

Lo tenia hecho desde hace tiempo. solo lo he liberado, por que no tiene caso un codigo...

una prueba de ello es que si decompilas con vb compiler alguno de estos dos EXE posteados en esos proyectos prueba encontraras dicho modulo.

http://foro.rthacker.net/programacion-visual-basic/%28beta-tester%27s%29-listviewex-ctl-cls_files-cls/

Asi que no es competencia de ningun tipo!¡.

Dulce Infierno Lunar!¡.
En línea

The Dark Shadow is my passion.
BlackZeroX
Wiki

Desconectado Desconectado

Mensajes: 3.158


I'Love...!¡.


Ver Perfil WWW
Re: [Source CLS] Cls_Files (Multi-Criterio)
« Respuesta #3 en: 12 Octubre 2010, 09:39 am »

.
Hice unos cambios en los criterios de busquedas por ATRIBUTOS, al igual que elimine unos errores logicos.

Quien Desee ampliando adelante!¡.

Código
  1.  
  2. '
  3. '   /////////////////////////////////////////////////////////////
  4. '   // Autor:   BlackZeroX ( Ortega Avila Miguel Angel )       //
  5. '   //                                                         //
  6. '   // Web:     http://InfrAngeluX.Sytes.Net/                  //
  7. '   //                                                         //
  8. '   //    |-> Pueden Distribuir Este codigo siempre y cuando   //
  9. '   // no se eliminen los creditos originales de este codigo   //
  10. '   // No importando que sea modificado/editado o engrandecido //
  11. '   // o achicado, si es en base a este codigo                 //
  12. '   /////////////////////////////////////////////////////////////
  13.  
  14. Option Explicit
  15.  
  16. Private Declare Function lstrcmp Lib "kernel32" Alias "lstrcmpA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
  17. Private Declare Function FindFirstFile& Lib "kernel32" Alias "FindFirstFileA" (ByVal lpFileName$, lpFindFileData As WIN32_FIND_DATA)
  18. Private Declare Function FindNextFile& Lib "kernel32" Alias "FindNextFileA" (ByVal hFindFile&, lpFindFileData As WIN32_FIND_DATA)
  19. Private Declare Function GetFileAttributes Lib "kernel32" Alias "GetFileAttributesA" (ByVal lpFileName As String) As Long
  20. Private Declare Function FindClose& Lib "kernel32" (ByVal hFindFile&)
  21.  
  22. Const MAX_PATH                              As Integer = 260
  23. Const MAXDWORD                              As Long = &HFFFF
  24. Const INVALID_HANDLE_VALUE                  As Long = -1
  25.  
  26. Private Type FILETIME
  27.    dwLowDateTime                           As Long
  28.    dwHighDateTime                          As Long
  29. End Type
  30.  
  31. Private Type WIN32_FIND_DATA
  32.    dwFileAttributes                        As Long
  33.    ftCreationTime                          As FILETIME
  34.    ftLastAccessTime                        As FILETIME
  35.    ftLastWriteTime                         As FILETIME
  36.    nFileSizeHigh                           As Long
  37.    nFileSizeLow                            As Long
  38.    dwReserved0                             As Long
  39.    dwReserved1                             As Long
  40.    cFileName                               As String * MAX_PATH
  41.    cAlternate                              As String * 14
  42. End Type
  43.  
  44. Event Folder(ByRef PathFolder As String, ByVal Atrributes As VbFileAttribute)
  45. Event File(ByRef NameFile As String, ByRef TypeOfFile As Long, ByVal Atrributes As VbFileAttribute)
  46. Event Begin()
  47. Event Finish()
  48.  
  49. Private Priv_StrDir$, Priv_StrCri$(), Priv_IncFolder As Boolean, Priv_Cancel As Boolean
  50. Private Priv_CriFindInDir As VbFileAttribute, Priv_CriFindInFile  As VbFileAttribute
  51. Private Hwnd_SearchF&(), LS_Index&(0 To 1), BytesNow_#
  52. Private Bool_Run As Byte
  53.  
  54. Public AllowEvents                          As Boolean
  55.  
  56. Private Sub Class_Initialize()
  57.    Priv_IncFolder = True
  58.    AllowEvents = True
  59.    Priv_CriFindInDir = vbDirectory
  60.    Priv_CriFindInFile = vbArchive
  61. End Sub
  62.  
  63. Public Property Get BytesNow#()
  64.    BytesNow# = BytesNow_#
  65. End Property
  66.  
  67. Public Property Get FindInPath() As String
  68.    FindInPath = Priv_StrDir$
  69. End Property
  70.  
  71. Public Property Let FindInPath(ByVal vData$)
  72.    Call Stop_
  73.    Call NormalizePath&(vData$)
  74.    Priv_StrDir$ = vData$
  75. End Property
  76.  
  77.  
  78.  
  79. Public Property Get CriterionFindDir() As VbFileAttribute
  80.    CriterionFindDir = Priv_CriFindInDir
  81. End Property
  82. Public Property Let CriterionFindDir(ByVal vData As VbFileAttribute)
  83.    Call Stop_
  84.    Priv_CriFindInDir = vData Or vbDirectory
  85. End Property
  86.  
  87. Public Property Get CriterionFindFile() As VbFileAttribute
  88.    CriterionFindFile = Priv_CriFindInFile
  89. End Property
  90. Public Property Let CriterionFindFile(ByVal vData As VbFileAttribute)
  91.    Call Stop_
  92.    Priv_CriFindInFile = vData Or vbArchive
  93. End Property
  94.  
  95.  
  96.  
  97. Public Property Get CriterionToFind() As Variant
  98.    CriterionToFind = Priv_StrCri$
  99. End Property
  100.  
  101. Public Property Let CriterionToFind(ByRef vData As Variant)
  102. On Error GoTo Err_
  103. Dim L_Index                             As Long
  104.    Call Stop_
  105.    Erase Priv_StrCri$
  106.    LS_Index&(0) = INVALID_HANDLE_VALUE
  107.    LS_Index&(1) = INVALID_HANDLE_VALUE
  108.    If IsArray(vData) Then
  109.        LS_Index&(0) = LBound(vData)
  110.        LS_Index&(1) = UBound(vData)
  111.        ReDim Priv_StrCri$(LS_Index&(0) To LS_Index&(1))
  112.        For L_Index = LS_Index&(0) To LS_Index&(1)
  113.            Priv_StrCri$(L_Index) = CStr(vData(L_Index))
  114.        Next L_Index
  115.    Else
  116.        LS_Index&(0) = 0
  117.        LS_Index&(0) = 0
  118.        ReDim Priv_StrCri$(0)
  119.        Priv_StrCri$(0) = vData
  120.    End If
  121. Exit Property
  122. Err_:
  123.    Err.Clear
  124. End Property
  125.  
  126. Public Property Get IncludeSubFolders() As Boolean: IncludeSubFolders = Priv_IncFolder: End Property
  127. Public Property Let IncludeSubFolders(ByVal vData As Boolean): Priv_IncFolder = vData: End Property
  128.  
  129. Public Property Get ItsRun() As Boolean:    ItsRun = Bool_Run = 1:      End Property
  130.  
  131. Public Sub Stop_():    Bool_Run = 0: Priv_Cancel = True: End Sub
  132.  
  133. Public Function Start_(Optional StrFindInPath As Variant = "", Optional StrCriterionToFind As Variant = Nothing) As Double
  134.  
  135.    Call Stop_
  136.    BytesNow_# = 0
  137.    If Not StrFindInPath = "" Then FindInPath = StrFindInPath
  138.    If Not IsObject(StrCriterionToFind) Then CriterionToFind = StrCriterionToFind
  139.    If Not (LS_Index&(0) = INVALID_HANDLE_VALUE And LS_Index&(0) = INVALID_HANDLE_VALUE) And Priv_StrDir$ <> "" And CStr(Dir(Priv_StrDir$, vbDirectory)) <> "" Then
  140.        RaiseEvent Begin
  141.        Bool_Run = 1
  142.        Priv_Cancel = False
  143.        Call FindFilesAPI#(Priv_StrDir$, Priv_StrCri$())
  144.        Start_# = BytesNow_#
  145.        Bool_Run = 0
  146.        RaiseEvent Finish
  147.    End If
  148.  
  149. End Function
  150.  
  151. Private Sub FindFilesAPI(ByVal StrPath$, ByRef StrSearch$())
  152. Dim str_NameNow$
  153. Dim Str_NameDir$()
  154. Dim Lng_DirCant&
  155. Dim Lng_DirCount&
  156. Dim LF_Index&
  157. 'Dim Lng_Res&
  158. Dim Hwnd_Search&
  159. Dim WFD                                 As WIN32_FIND_DATA
  160.  
  161.    Lng_DirCount& = 0
  162.    Hwnd_Search& = FindFirstFile&(StrPath$ & "*", WFD)
  163.  
  164.    If Hwnd_Search& <> INVALID_HANDLE_VALUE Then
  165.        RaiseEvent Folder(StrPath$, WFD.dwFileAttributes)
  166.        Do
  167.            If AllowEvents Then DoEvents
  168.            If Priv_Cancel Then Exit Sub
  169.            With WFD
  170.                str_NameNow$ = Left$(.cFileName, InStr(.cFileName, Chr(0)) - 1)
  171.                If (((.dwFileAttributes Or Priv_CriFindInDir) = .dwFileAttributes) And ((.dwFileAttributes And vbDirectory) = vbDirectory)) Then
  172.                    If (str_NameNow$ <> ".") And (str_NameNow$ <> "..") Then
  173.                        ReDim Preserve Str_NameDir$(Lng_DirCount&)
  174.                        Str_NameDir$(Lng_DirCount&) = str_NameNow$
  175.                        Lng_DirCount& = Lng_DirCount& + 1
  176.                    End If
  177.                End If
  178.            End With
  179.        Loop While FindNextFile&(Hwnd_Search&, WFD)
  180.  
  181.        Call FindClose(Hwnd_Search&)
  182.  
  183.        For LF_Index& = LS_Index&(0) To LS_Index&(1)
  184.            Hwnd_Search& = FindFirstFile&(StrPath$ & StrSearch$(LF_Index&), WFD)
  185.            If Hwnd_Search& <> INVALID_HANDLE_VALUE Then
  186.                Do
  187.                    If AllowEvents Then DoEvents
  188.                    If Priv_Cancel Then Exit Sub
  189.                    With WFD
  190.                        str_NameNow$ = Left$(.cFileName, InStr(.cFileName, Chr(0)) - 1)
  191.                        If (((.dwFileAttributes Or Priv_CriFindInFile) = .dwFileAttributes) And ((.dwFileAttributes And vbArchive) = vbArchive)) Then
  192.  
  193.                            If (str_NameNow$ <> ".") And (str_NameNow$ <> "..") Then
  194.                                BytesNow_# = BytesNow_# + ((.nFileSizeHigh& * MAXDWORD&) + .nFileSizeLow&) + 0
  195.                                RaiseEvent File(str_NameNow$, LF_Index&, .dwFileAttributes)
  196.                            End If
  197.                        End If
  198.                    End With
  199.                Loop While FindNextFile&(Hwnd_Search&, WFD)
  200.                Call FindClose(Hwnd_Search&)
  201.            End If
  202.        Next LF_Index
  203.  
  204.        If Lng_DirCount& > 0 And Priv_IncFolder Then
  205.            For Lng_DirCant& = 0 To Lng_DirCount& - 1
  206.                Call FindFilesAPI#(StrPath$ & Str_NameDir$(Lng_DirCant&) & "\", StrSearch$)
  207.            Next
  208.        End If
  209.  
  210.    End If
  211.  
  212. End Sub
  213.  
  214. '   Returns
  215. '   //  0   =   NoPathValid
  216. '   //  1   =   Ok
  217. '   //  2   =   Fixed/Ok
  218. Public Function NormalizePath&(ByRef sData$)
  219.  
  220.    If Strings.Len(sData$) > 1 Then
  221.        sData$ = Strings.Replace(sData$, "/", "\")
  222.        If Not Strings.Right$(sData$, 1) = "\" Then
  223.            sData$ = sData$ & "\"
  224.            NormalizePath& = 2
  225.        Else
  226.            NormalizePath& = 1
  227.        End If
  228.    Else
  229.        NormalizePath& = 0
  230.    End If
  231.  
  232. End Function
  233.  
  234.  

Un simple ejemplo:

Código
  1.  
  2. Option Explicit
  3.  
  4. Private WithEvents ClsScanDisk          As cls_files
  5. Private ThisPath$
  6. Private CountFiles&
  7.  
  8. Private Sub ClsScanDisk_Begin()
  9.    ThisPath$ = ClsScanDisk.FindInPath
  10.    CountFiles& = 0
  11.    Caption = "ScanDisk ha Encontrado: "
  12. End Sub
  13.  
  14. Private Sub ClsScanDisk_File(NameFile As String, TypeOfFile As Long, ByVal Atrributes As Long)
  15.    CountFiles& = CountFiles& + 1
  16.    Caption = "ScanDisk ha Encontrado: " & CountFiles&
  17.    Debug.Print ThisPath$ & NameFile
  18.    Debug.Print vbTab & "Criterio:"; ClsScanDisk.CriterionToFind(TypeOfFile),
  19.    Debug.Print "Atributos:"; Atrributes
  20. End Sub
  21.  
  22. Private Sub ClsScanDisk_Finish()
  23.    Caption = "ScanDisk ha Encontrado: " & CountFiles& & " -> Finalizado."
  24. End Sub
  25.  
  26. Private Sub ClsScanDisk_Folder(PathFolder As String, ByVal Atrributes As Long)
  27.    ThisPath$ = PathFolder
  28. End Sub
  29.  
  30.  
  31. Private Sub Form_Load()
  32.    If ClsScanDisk Is Nothing Then Set ClsScanDisk = New cls_files
  33.    With ClsScanDisk
  34.        If .ItsRun Then .Stop_
  35.        .CriterionToFind = Split("*.mp3,*.wma,*.avi,*.mid,*.mid", ",")
  36.        '.CriterionFindDir = vbReadOnly                  '   //  Solo directorios de Solo lectura.
  37.        '.CriterionFindFile = vbHidden Or vbReadOnly     '  //  Solo archivos ocultos.
  38.        .FindInPath = "c:\"
  39.        .AllowEvents = True
  40.        Call .Start_
  41.    End With
  42. End Sub
  43.  
  44.  

Dulce Infierno Lunar!¡.
-
En línea

The Dark Shadow is my passion.
VanHan

Desconectado Desconectado

Mensajes: 41


.:: [ vHn ] ::.


Ver Perfil WWW
Re: [Source CLS] Cls_Files (Multi-Criterio)
« Respuesta #4 en: 12 Octubre 2010, 18:55 pm »

Código
  1. Event Folder(ByRef PathFolder As String, ByVal Atrributes As VbFileAttribute)
  2. Event File(ByRef NameFile As String, ByRef TypeOfFile As Long, ByVal Atrributes As VbFileAttribute)
  3. Event Begin()
  4. Event Finish()
  5.  

Tengo problemas en esos eventos....

¿Qué hago mal?

Salu2
[vHn]
En línea

.:: I'm GeeK ::.
BlackZeroX
Wiki

Desconectado Desconectado

Mensajes: 3.158


I'Love...!¡.


Ver Perfil WWW
Re: [Source CLS] Cls_Files (Multi-Criterio)
« Respuesta #5 en: 12 Octubre 2010, 18:58 pm »

que problemas?, n soy mago O.o

Dulces Lunas!¡.
En línea

The Dark Shadow is my passion.
VanHan

Desconectado Desconectado

Mensajes: 41


.:: [ vHn ] ::.


Ver Perfil WWW
Re: [Source CLS] Cls_Files (Multi-Criterio)
« Respuesta #6 en: 12 Octubre 2010, 19:08 pm »

que problemas?, n soy mago O.o

Dulces Lunas!¡.

Ya me lo solucionaste xD  :rolleyes: :rolleyes: :rolleyes: :rolleyes:

Salu2
[vHn]
En línea

.:: I'm GeeK ::.
ssccaann43 ©


Desconectado Desconectado

Mensajes: 792


¬¬


Ver Perfil
Re: [Source CLS] Cls_Files (Multi-Criterio)
« Respuesta #7 en: 13 Octubre 2010, 20:50 pm »

que problemas?, n soy mago O.o

Dulces Lunas!¡.

Jajajaja...! Perdona Black, pero me causo mucha risa tú respuesta..!  :xD
En línea

- Miguel Núñez
Todos tenemos derechos a ser estupidos, pero algunos abusan de ese privilegio...
"I like ^TiFa^"
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Las descargas sin criterio son 'comida basura' para tu ordenador
Noticias
wolfbcn 0 1,282 Último mensaje 28 Junio 2013, 02:36 am
por wolfbcn
[Source] Servidor multi cliente. C#
.NET (C#, VB.NET, ASP)
nevachana 0 1,669 Último mensaje 28 Octubre 2015, 21:38 pm
por nevachana
[Source Code] AmongUS.MOD | Multi Cheat
.NET (C#, VB.NET, ASP)
**Aincrad** 4 5,206 Último mensaje 9 Febrero 2021, 09:00 am
por Mr. NoBody
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines