Me gustaria poder utilizar en una aplicacion de visual basic un common dialog como el de abrir ficheros, pero q en vez de seleccionarme un fichero me seleccione un directorio.
Espero q alguien me pueda echar una mano.
Gracias
![Adios](http://static.forosdelweb.com/fdwtheme/images/smilies/adios.gif)
| |||
![]() Aupa, Me gustaria poder utilizar en una aplicacion de visual basic un common dialog como el de abrir ficheros, pero q en vez de seleccionarme un fichero me seleccione un directorio. Espero q alguien me pueda echar una mano. Gracias ![]() |
| |||
![]() Tranquilo mesna y gracias de todos modos, ya encontrado la solucion a lo q queria hacer. He estado buscando ![]() 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 ![]() |