Click to See Complete Forum and Search --> : what happens.....


Andrea_Rossini
August 9th, 2006, 11:25 AM
What happens if I use....


Public Function BrowseForFolder(ByVal hWnd As Long, ByVal Titolo As String) As String
Dim bInfo As BROWSEINFO
Dim pidl As Long
Dim tit(0 To 512) As Byte
Dim ret As String
Dim lpMalloc As IVBMalloc
ret = ""

CopyMemoryStr tit(0), Titolo, Len(Titolo) + 1

With bInfo
.hwndOwner = hWnd
.pidlRoot = 0 ' NULL
.lpfn = 0
.lpszTitle = VarPtr(tit(0))
.pszDisplayName = VarPtr(tit(0))
.ulFlags = BIF_EDITBOX Or BIF_RETURNONLYFSDIRS
End With

pidl = SHBrowseForFolder(bInfo)

If pidl <> 0 Then
ret = Space$(511)
SHGetPathFromIDList pidl, ret
ret = Trim(ret)
ret = Left(ret, Len(ret) - 1)

SHGetMalloc lpMalloc

If Not lpMalloc Is Nothing Then
lpMalloc.Free pidl
End If

Set lpMalloc = Nothing
End If
BrowseForFolder = ret
End Function