Has any one used these network browsing functions? I'm trying to show the network browsing dialog, then retrieve the name of the selected computer...
This is what I've got:
Can anyone make this work?? Please help!Code:Option Explicit Const MAXPATH = 260 Const CSIDL_NETWORK = 18 Const CSIDL_DESKTOP = 0 Const BIF_RETURNONLYFSDIRS = &H1 ' For finding a folder to start document searching Const BIF_DONTGOBELOWDOMAIN = &H2 ' For starting the Find Computer Const BIF_STATUSTEXT = &H4 Const BIF_RETURNFSANCESTORS = &H8 Const BIF_EDITBOX = &H10 Const BIF_VALIDATE = &H20 ' insist on valid result (or CANCEL) Const BIF_BROWSEFORCOMPUTER = &H1000 ' Browsing for Computers. Const BIF_BROWSEFORPRINTER = &H2000 ' Browsing for Printers Const BIF_BROWSEINCLUDEFILES = &H4000 ' Browsing for Everything Private Type BROWSEINFO hwndOwner As Long pidlRoot As Long strDisplayName As Long strTitle As Long ulFlags As Long lpfn As Long lParam As Long iImage As Long End Type Private Declare Function GlobalFree Lib "kernel32" (ByVal pntr As Long) As Long Private Declare Function SHGetSpecialFolderLocation Lib "Shell32" (ByVal hwnd As Long, _ ByVal lpstr As Long, ByRef pntr As Long) As Long Private Declare Function SHGetPathFromIDList Lib "Shell32" (ByVal pntr As Long, _ ByRef str As String) As Long Private Declare Function SHBrowseForFolder Lib "Shell32" (ByVal pntr As Long) As Long Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _ (Destination As Long, Source As Long, ByVal Length As Long) Private Sub Command1_Click() Dim udtBrowse As BROWSEINFO Dim lngIdl As Long Dim nHwndFlag As Long Dim nResult As Long Dim szPath As String, szDLL As String, szParameter As String Dim pszOperation As Long, pszFile As Long, pszPath As Long, pszParameter As Long Dim pudtBrowse As Long, pstrPath As Long, pstrTitle As Long Dim strPath As String * MAXPATH Dim strTitle As String * MAXPATH Dim nReturn As Long Dim nFolder As Long nFolder = CSIDL_NETWORK nResult = SHGetSpecialFolderLocation(Me.hwnd, nFolder, lngIdl) If nResult = 0 Then strPath = "" strTitle = "Arse Beaver" & vbNullChar pstrPath = StrPtr(strPath) pstrTitle = StrPtr(strTitle) udtBrowse.hwndOwner = Me.hwnd udtBrowse.pidlRoot = lngIdl 'udtBrowse.strDisplayName = pstrPath udtBrowse.strTitle = pstrTitle udtBrowse.ulFlags = BIF_BROWSEFORCOMPUTER 'BIF_RETURNONLYFSDIRS pudtBrowse = VarPtr(udtBrowse) lngIdl = SHBrowseForFolder(pudtBrowse) If lngIdl <> 0 Then ' 'strPath = String(512, vbNullChar) ' nResult = SHGetPathFromIDList(lngIdl, strPath) ' Label1.Caption = strPath ' GlobalFree (lngIdl) End If End If End Sub



Reply With Quote