Results 1 to 4 of 4

Thread: Access Network NeighbourHood from VB

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 1999
    Location
    B
    Posts
    1

    Post

    I want to access the Network Neighbourhood inside my application.

    I need to access all the PCs in the NtkNeighbourhood, so that the user
    of my application can select a PC of his choice.

    Can any one tell me how to display all the PCs in the neighbourhood ?

    ------------------

  2. #2
    New Member
    Join Date
    May 1999
    Location
    Newton Iowa USA
    Posts
    1

    Post

    Use the API calls WNETOpenEnum and WNetEnumResource.

    Type NetResource
    dwScope As NetResourceScope
    dwType As NetResourceType
    dwDisplayType As NetResourceDisplayType
    dwUsage As NetResourceUsage
    lpLocalName As Long
    lpRemoteName As Long
    lpComment As Long
    lpProvider As Long
    End Type
    dim nr as NetResource

    NetworkError = WNetOpenEnum(RESOURCE_GLOBALNET, RESOURCETYPE_ANY, 0,0 ,hEnum)

    NetworkError = WNetEnumResource(hEnum, cCount, nr(0), cbBuff)

    I have created a network neighborhood look-a-like with these routines.

    Wes G.

  3. #3
    Guest

    Post

    Could someone please put in more detail on doing this.

    I am making a comparison program and I need access to the network neighborhood. at the moment that code screws up, I added some code to it like the API calls and then I custommly put in teh type but still no good!

    Is it possible to get some working code and maybe some example project or something for it.

    Please help me

  4. #4
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    Here's one I just finished, it displays a Browse Dialog of the Network Neighbourhood and Returns the Name of the Computer Selected..

    In a Module..
    Code:
    Private Type SHITEMID
        cb As Long
        abID As Byte
    End Type
    
    Private Type ITEMIDLIST
        mkid As SHITEMID
    End Type
    
    Private Type BROWSEINFO
        hwndOwner As Long
        pIDLRoot As Long
        pszDisplayName As Long
        lpszTitle As Long
        ulFlags As Long
        lpfnCallback As Long
        lParam As Long
        iImage As Long
    End Type
    
    Private Declare Function SHGetSpecialFolderLocation Lib "shell32.dll" (ByVal hwndOwner As Long, ByVal nFolder As Long, pidl As ITEMIDLIST) As Long
    Private Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BROWSEINFO) As Long
    Private Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
    Private Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)
        
    Private Const FLDR_NETWORK = &H12
    Private Const BIF_BROWSEFORCOMPUTER = 4096
    
    Public Function BrowseNetwork(ByVal lHwnd As Long, ByVal sTitle As String) As String
        Dim tIDL As ITEMIDLIST
        Dim lIDList As Long
        Dim sBuffer As String
        Dim tBI As BROWSEINFO
        Dim sComputer As String
        Dim lFolder As Long
        
        lret = SHGetSpecialFolderLocation(0, FLDR_NETWORK, tIDL)
        
        sComputer = Space(260)
        With tBI
            .hwndOwner = lHwnd
            .pIDLRoot = tIDL.mkid.cb
            .lpszTitle = lstrcat(sTitle, "")
            .ulFlags = BIF_BROWSEFORCOMPUTER
            .pszDisplayName = StrPtr(sComputer)
        End With
        
        lIDList = SHBrowseForFolder(tBI)
    
        sComputer = StrConv(sComputer, vbUnicode)
        BrowseNetwork = Left(sComputer, InStr(sComputer, Chr(0)) - 1)
        Call CoTaskMemFree(lIDList)
    End Function
    In the Form..
    Code:
    Private Sub Command1_Click()
        Caption = BrowseNetwork(hWnd, "Select a Computer..")
    End Sub

    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width