>>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
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement