Results 1 to 5 of 5

Thread: find all computers on a network...

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2001
    Posts
    253

    find all computers on a network...

    ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
    Last edited by smashtheqube; Jan 11th, 2019 at 12:58 AM.

  2. #2
    Fanatic Member
    Join Date
    Sep 2002
    Location
    Lexington, SC
    Posts
    586
    Hmm I'm not sure how windows treats networked computers but you can probably check around in the registry. I found a spot in there under HKEY_LOCAL_MACHINE\System\MountedDevices that had my regular drives pluse a few \??\Volume-{volumekey} listed.

    I know that these are mounted remote drives or folders that I have shared. Not sure if there is a place in there that lists networked computers that dont have sharing enabled. But its a start =p

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    This will load all domains and respective computers regardless of sharing.
    VB Code:
    1. 'IN A MODULE
    2. Option Explicit
    3.  
    4. Public Type SERVER_INFO_100
    5.     sv100_platform_id As Long
    6.     sv100_name As Long
    7. End Type
    8.  
    9. Public Const SV_TYPE_DOMAIN_ENUM         As Long = &H80000000
    10. Public Const SV_TYPE_ALL                 As Long = &HFFFFFFFF
    11. Public Const MAX_PREFERRED_LENGTH As Long = -1
    12. Public Const NERR_SUCCESS As Long = 0&
    13. Public Const ERROR_REQ_NOT_ACCEP = 71&
    14. Public Const ERROR_MORE_DATA As Long = 234&
    15. Public Const NERR_BASE = 2100
    16. Public Const NERR_InvalidComputer = (NERR_BASE + 251)
    17.  
    18. Public Declare Function NetServerEnum Lib "netapi32" (ByVal servername As Long, ByVal level As Long, buf As Any, _
    19. ByVal prefmaxlen As Long, entriesread As Long, totalentries As Long, ByVal servertype As Long, ByVal domain As Long, _
    20. resume_handle As Long) As Long
    21.  
    22. Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pTo As Any, uFrom As Any, ByVal lSize As Long)
    23.    
    24. Public Declare Function NetApiBufferFree Lib "netapi32" (ByVal Buffer As Long) As Long
    25.  
    26. Public Declare Function lstrlenW Lib "kernel32" (ByVal lpString As Long) As Long
    27.  
    28. Public Function GetServers(sDomain As String, sType As Long) As String()
    29.  
    30.     Dim bufptr          As Long
    31.     Dim dwEntriesread   As Long
    32.     Dim dwTotalentries  As Long
    33.     Dim dwResumehandle  As Long
    34.     Dim se100           As SERVER_INFO_100
    35.     Dim success         As Long
    36.     Dim nStructSize     As Long
    37.     Dim Cnt             As Long
    38.    
    39.     nStructSize = LenB(se100)
    40.     success = NetServerEnum(0&, 100, bufptr, MAX_PREFERRED_LENGTH, dwEntriesread, dwTotalentries, sType, StrPtr(sDomain), dwResumehandle)
    41.     'success = 71 'NO ACTIVE 'DOMAIN'
    42.     If success = NERR_SUCCESS And success <> ERROR_MORE_DATA Then
    43.         Dim compNames() As String
    44.         ReDim compNames(dwEntriesread)
    45.         For Cnt = 0 To dwEntriesread - 1
    46.             CopyMemory se100, ByVal bufptr + (nStructSize * Cnt), nStructSize
    47.             compNames(Cnt) = GetPointerToByteStringW(se100.sv100_name)
    48.             DoEvents
    49.         Next
    50.     End If
    51.     Call NetApiBufferFree(bufptr)
    52.     GetServers = compNames
    53.    
    54. End Function
    55.  
    56. Public Function GetPointerToByteStringW(ByVal dwData As Long) As String
    57.  
    58.     Dim tmp() As Byte
    59.     Dim tmplen As Long
    60.    
    61.     If dwData <> 0 Then
    62.         tmplen = lstrlenW(dwData) * 2
    63.         If tmplen <> 0 Then
    64.             ReDim tmp(0 To (tmplen - 1)) As Byte
    65.             CopyMemory tmp(0), ByVal dwData, tmplen
    66.             GetPointerToByteStringW = tmp
    67.         End If
    68.     End If
    69.    
    70. End Function
    71.  
    72. 'BEHIND A FORM WITH TWO COMBOS (cboDomain AND cboComputer)
    73. Private Sub Form_Load()
    74.  
    75.     Dim compNames() As String
    76.     Dim x As Integer
    77.  
    78.     'SETUP THE DOMAIN COMBO BOX
    79.     compNames = GetServers(vbNullString, SV_TYPE_DOMAIN_ENUM)
    80.     For x = LBound(compNames) To UBound(compNames) - 1
    81.         cboDomain.AddItem compNames(x)
    82.     Next
    83.     cboDomain.ListIndex = 0
    84.  
    85. End Sub
    86.  
    87. Private Sub cboDomain_Click()
    88.     'NEED TO CLEAR CBOCOMPUTER AND RELOAD WITH COMPUTERS IN THE NEWLY SELECTED DOMAIN
    89.     'SETUP THE COMPUTER COMBO BOX
    90.     On Error GoTo No_Bugs
    91.    
    92.     Dim compNames() As String
    93.     Dim x As Integer
    94.    
    95.     cboComputer.Clear
    96.     x = 0
    97.     compNames = GetServers(cboDomain.Text, SV_TYPE_ALL)
    98.     If UBound(compNames) > 0 Then
    99.         For x = LBound(compNames) To UBound(compNames) - 1
    100.             cboComputer.AddItem compNames(x)
    101.         Next
    102.         cboComputer.ListIndex = 0
    103.     End If
    104.     Exit Sub
    105.    
    106. No_Bugs:
    107.     If Err.Number = "9" Then
    108.         cboDomain.RemoveItem (cboDomain.ListIndex)
    109.         cboDomain.ListIndex = 0
    110.         compNames = GetServers(cboDomain.Text, SV_TYPE_ALL)
    111.         Resume
    112.     Else
    113.         MsgBox Err.Number & " - " & Err.Description, vbOKOnly + vbExclamation, App.ProductName
    114.     End If
    115.    
    116. End Sub
    Enjoy
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Feb 2001
    Posts
    253
    ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
    Last edited by smashtheqube; Jan 11th, 2019 at 12:58 AM.

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Are you running a domain or workgroup?

    If you are running a domain, it will find all computers that are on-line.
    If you are running a workgroup then I'm not sure, since I am
    running a domain I can't test it.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

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