Ver Mensaje Individual
  #3 (permalink)  
Antiguo 01/04/2004, 06:03
Lillo
 
Fecha de Ingreso: febrero-2004
Ubicación: Bilbao
Mensajes: 5
Antigüedad: 20 años, 2 meses
Puntos: 0

Tranquilo mesna y gracias de todos modos, ya encontrado la solucion a lo q queria hacer.
He estado buscando por ahi y encontrado un trozo de codigo q me sirve.
Lo pongo a continuación por si le puede servir a alguien, q este buscando algo como esto:

Const MAX_PATH = 255

Private Enum eBIF
BIF_RETURNONLYFSDIRS = &H1 'Sólo directorios del sistema
BIF_DONTGOBELOWDOMAIN = &H2 'No incluir carpetas de red
BIF_STATUSTEXT = &H4
BIF_RETURNFSANCESTORS = &H8
BIF_BROWSEFORCOMPUTER = &H1000 'Buscar PCs
BIF_BROWSEFORPRINTER = &H2000 'Buscar impresoras
End Enum

Private Type BrowseInfo
hwndOwner As Long
pIDLRoot As Long 'Especifica dónde se empezará a mostrar
pszDisplayName As Long
lpszTitle As Long
ulFlags As Long
lpfnCallback As Long
lParam As Long
iImage As Long
End Type

Private Declare Function SHBrowseForFolder Lib "shell32.dll" _
(lpbi As BrowseInfo) As Long

Private Declare Sub CoTaskMemFree Lib "ole32.dll" _
(ByVal hMem As Long)

Private Declare Function lstrcat Lib "kernel32.dll" Alias "lstrcatA" _
(ByVal lpString1 As String, ByVal lpString2 As String) As Long

Private Declare Function SHGetPathFromIDList Lib "shell32.dll" _
(ByVal pidList As Long, ByVal lpBuffer As String) As Long


Private Function BrowseForFolder(ByVal hwndOwner As Long, ByVal sPrompt As String, Optional ByVal vFlags As eBIF) As String

Dim iNull As Integer
Dim lpIDList As Long
Dim lResult As Long
Dim sPath As String
Dim udtBI As BrowseInfo
Dim lFlags As Long

If Not IsMissing(vFlags) Then
lFlags = CInt(vFlags)
End If

With udtBI
.hwndOwner = hwndOwner
.lpszTitle = lstrcat(sPrompt, "")
.ulFlags = lFlags Or BIF_RETURNONLYFSDIRS
End With

lpIDList = SHBrowseForFolder(udtBI)
If lpIDList Then
sPath = String$(MAX_PATH, 0)
lResult = SHGetPathFromIDList(lpIDList, sPath)
Call CoTaskMemFree(lpIDList)
iNull = InStr(sPath, vbNullChar)
If iNull Then
sPath = Left$(sPath, iNull - 1)
End If
Else
'Se ha pulsado en cancelar
sPath = "" ' y lo q quieras q devuelva
End If
BrowseForFolder = sPath
End Function

'''''' Y se le da esta utilidad p.ej.

Private Sub Cmd_Command1_Click()
Label1.Caption = BrowseForFolder(Me.Hwnd, "Selecciona un directorio")
End Sub