Hi Holmes
I do have one solution for your problem above but I don't know if this solution helpful and if its helpful I hope it not too late. All you need is just a command button and list.
First of all you need to declare these, either in module or just in your form:
Private 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
Dim b1 As BROWSEINFO
Dim r As Long
Dim fPath As String
Dim fName As String
Dim foldB As Long
Dim tempPath As String
Dim Pos As Integer
Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
Private Declare Function SHBrowseForFolder Lib "shell32.dll" Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long
Then you need to apply this function afterward:
Private Function GetBrowsersDirectory() As String
foldB = SHBrowseForFolder(b1)
tempPath = Space$(512)
r = SHGetPathFromIDList(ByVal foldB, ByVal tempPath)
If r Then
Pos = InStr(tempPath, Chr$(0))
tempPath = Left(tempPath, Pos - 1)
GetBrowsersDirectory = tempPath
Else: GetBrowsersDirectory = ""
End If
End Function
Then under command button which I name command1 you put this code:
Private Sub Command1_Click()
On Error Resume Next
fPath$ = GetBrowsersDirectory$()
If fPath$ > "" Then
fName$ = fPath
SetAttr fName, vbReadOnly
List1.AddItem LCase(fName)
End If
'If you want to remove duplicate folder on the list
Dim i, x
For i = 0 To List1.ListCount - 1
For x = 0 To List1.ListCount - 1
If i = x Then GoTo NextX
If LCase(List1.List(x)) = LCase(List1.List(i)) Then
List1.RemoveItem x
End If
NextX:
Next x
Next i
End Sub
Hope this solution is helpful and can solve your problem.
Regards;
Raja Mohd Hisham
Enter your message below
Sign in or Join us (it's free).