Network Browser - Updated
I needed a way to select a network share, As I couldn't find any source I had to put this together. So now I am sharing it for others, enjoy
AI
AI Samenvatting: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Broncode
Public Function GetBrowseNetworkShare(ByVal hw As Variant) As String
'returns only a valid share on a network server or workstation
' hw is a forms hWnd
' call: Text1.Text = GetBrowseNetworkShare(Me.hWnd)
Dim BI As BROWSEINFO
Dim pidl As Long
Dim sPath As String
Dim pos As Integer
If SHGetSpecialFolderLocation(0, CSIDL_NETWORK, pidl) = ERROR_SUCCESS Then
With BI
.hOwner = hw
.pidlRoot = pidl
.pszDisplayName = Space$(MAX_PATH)
.lpszTitle = "Select a network computer or share."
.ulFlags = BIF_RETURNONLYFSDIRS
End With
'show the browse dialog
pidl = SHBrowseForFolder(BI)
If pidl <> 0 Then
sPath = Space$(MAX_PATH)
If SHGetPathFromIDList(ByVal pidl, ByVal sPath) Then
pos = InStr(sPath, Chr$(0))
GetBrowseNetworkShare = Left$(sPath, pos - 1)
End If
Else:
GetBrowseNetworkShare = "\\" & BI.pszDisplayName
End If 'If pidl
End If 'If SHGetSpecialFolderLocation
End Function
Originele reacties (3)
Hersteld van de Wayback Machine