Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
I need select directory (not file)
Message
De
28/04/1999 16:20:22
Alex Zhadanov
Computer Generated Solutions
New York City, New York, États-Unis
 
 
À
26/04/1999 13:38:59
Information générale
Forum:
Visual Basic
Catégorie:
Autre
Divers
Thread ID:
00212134
Message ID:
00213181
Vues:
29
>>Hi all.
>>Is there equvalent of VFP function getdir()?
>>I need to choose directory. If i use common dialig control i can only
>>select files in directory not directory itself.
>>Thank you Alex
>
>Put The Following Code In A Module:
>--CODE START---
>Option Explicit
>
>Public Declare Function SHGetPathFromIDList Lib "shell32.dll" _
>Alias "SHGetPathFromIDListA" (ByVal pidl As Long, _
>ByVal pszPath As String) As Long
>
>Public Type BROWSEINFO
> hOwner As Long
> pidlRoot As Long
> pszDisplayName As String
> lpszTitle As String
> ulFlags As Long
> lpfn As Long
> lParam As Long
> iImage As Long
>End Type
>
>Public Declare Function SHBrowseForFolder Lib "shell32.dll" _
>Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long
>
>Public Const BIF_RETURNONLYFSDIRS = &H1
>Public Const BIF_DONTGOBELOWDOMAIN = &H2
>Public Const BIF_RETURNFSANCESTORS = &H8
>Public Const BIF_BROWSEFORCOMPUTER = &H1000
>Public Const BIF_BROWSEFORPRINTER = &H2000
>Const BIF_STATUSTEXT = &H4
>
>Function SelectFolder(Title As String) As String
>
>Dim udtBrowseInfo As BROWSEINFO
>Dim lRet As Long
>Dim lPathID As Long
>Dim sPath As String
>Dim nNullPos As Integer
>
>udtBrowseInfo.hOwner = frmMain.hwnd
>udtBrowseInfo.pidlRoot = 0&
>udtBrowseInfo.lpszTitle = Title
>udtBrowseInfo.ulFlags = BIF_RETURNONLYFSDIRS
>lPathID = SHBrowseForFolder(udtBrowseInfo)
>sPath = Space$(512)
>lRet = SHGetPathFromIDList(lPathID, sPath)
>SelectFolder = Trim$(sPath)
>SelectFolder = Left(SelectFolder, Len(SelectFolder) - 1)
>If Right(SelectFolder, 1) <> "\" Then
> SelectFolder = SelectFolder & "\"
>End If
>
>End Function
>--CODE END--
>
>Now You Can Just Make A Call To SelectFolder And You Can Specify What You Want
>To Appear As The Title For The Directory Box!
>
>EXAMPLE: SelectFolder("Please Select The Directory To Install Data Files To:")
>
>Hope This Helps!!!!
Thank you.
It works fine.
Alex
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform