Foro de elhacker.net

Programación => Programación Visual Basic => Mensaje iniciado por: Anteros en 22 Mayo 2008, 21:02 pm



Título: duda: carpetas ocultas y dirlistbox
Publicado por: Anteros en 22 Mayo 2008, 21:02 pm
Holas gente!...tengo un duda...como puedo hacer para q un dirlistbox pueda mostrar carpetas ocultas??...y si no se puede habra por ahi algun control parecido al dirlistbox q me permita hacer esto??

gracias por todo de antemano


Título: Re: duda: carpetas ocultas y dirlistbox
Publicado por: SKL (orignal) en 22 Mayo 2008, 22:03 pm
no y no.


sl2


Título: Re: duda: carpetas ocultas y dirlistbox
Publicado por: seba123neo en 22 Mayo 2008, 23:59 pm
Hola,con ese control no se puede parece,pero desde codigo podes sacarlos algo asi:

Código:
Private Sub Form_Load()
Dim Ocultos As String
Ocultos = Dir("c:\", vbDirectory + vbHidden)
Do While Ocultos <> ""
Debug.Print Ocultos
Ocultos = Dir
Loop
End Sub

EDIT:Aca esta  :P

Código:
Option Explicit

Private Const MAX_PATH = 260
Private Type FILETIME
        dwLowDateTime As Long
        dwHighDateTime As Long
End Type
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

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 Const LB_GETCOUNT = &H18B
Private Const LB_INSERTSTRING = &H181
Private Const LB_ERR = (-1)


Private Const FILE_ATTRIBUTE_HIDDEN = &H2
Private Const FILE_ATTRIBUTE_SYSTEM = &H4
Private Const FILE_ATTRIBUTE_DIRECTORY = &H10


Private Declare Function SendMessageString Lib "user32" Alias "SendMessageA" _
    (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
    ByVal lParam As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
    (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
    lParam As Any) As Long


Private Sub ShowHiddenDirectories(DirCtrl As DirListBox, Optional bShowSystem As Boolean)
    Dim res As Long
    Dim sF As String, sDirPath
    Dim FData As WIN32_FIND_DATA
    Dim fHand As Long, i As Long
    Dim level As Long
    Dim StillOK As Long
    Const HIDDEN_DIRECTORY = FILE_ATTRIBUTE_DIRECTORY Or FILE_ATTRIBUTE_HIDDEN
    sDirPath = DirCtrl.Path
    If Right$(sDirPath, 1) <> "\" Then sDirPath = sDirPath & "\"
    res = SendMessage(DirCtrl.hwnd, LB_GETCOUNT, 0, 0)
    If res = LB_ERR Then Exit Sub
    level = res - DirCtrl.ListCount
    fHand = FindFirstFile(sDirPath & "*", FData)
    StillOK = fHand
    Do While StillOK > 0
        If (FData.dwFileAttributes And HIDDEN_DIRECTORY) >= HIDDEN_DIRECTORY Then
           If bShowSystem Or ((FData.dwFileAttributes And FILE_ATTRIBUTE_SYSTEM) = 0) Then
            sF = CutRightAt(FData.cFileName)
            If sF <> "." And sF <> ".." Then
                i = DirCtrl.ListCount
                Do
                    If i > 0 Then
                        res = StrComp(sF, Right(DirCtrl.List(i - 1), Len(DirCtrl.List(i - 1)) - Len(sDirPath)), vbTextCompare)
                        If res >= 0 Then
                            If res Then res = SendMessageString(DirCtrl.hwnd, LB_INSERTSTRING, i + level, sF)
                            Exit Do
                       
                        End If
                    Else
                        If i = 0 Then res = SendMessageString(DirCtrl.hwnd, LB_INSERTSTRING, i + level, sF)
                    End If
                    i = i - 1
                Loop While i >= 0
            End If
           End If
        End If

        StillOK = FindNextFile(fHand, FData)
    Loop

    fHand = FindClose(fHand)
End Sub

Private Function CutRightAt(NormString As String, Optional ascii As Long = 0) As String
    Dim i As Long
    i = InStr(1, NormString, Chr(ascii), vbBinaryCompare)
    If i Then
        CutRightAt = Left(NormString, i - 1)
    Else
        CutRightAt = NormString
    End If
End Function

Private Sub Dir1_Change()
    ShowHiddenDirectories Dir1, True
End Sub


 :P :P

saludos.



Título: Re: duda: carpetas ocultas y dirlistbox
Publicado por: Anteros en 27 Mayo 2008, 18:33 pm
...como q no se podia???....muxas gracias seba123neo!!! ...lo maximo!!!