Results 1 to 12 of 12

Thread: Winsock

  1. #1

    Thread Starter
    Junior Member davism's Avatar
    Join Date
    Jan 2004
    Location
    Rotherham, UK
    Posts
    30

    Winsock

    Hi,

    Is there any possible way to view all the Computers which are turned on , on your LAN as icons so you may select them and use there IP address'.

    Thanx

  2. #2
    Addicted Member Psychotic's Avatar
    Join Date
    May 2004
    Posts
    164
    You could probably do this by pinging the ips on the LAN
    -Psychotic-

  3. #3
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901
    NET USER will give you the username of everyone that's connected at the time.

  4. #4

    Thread Starter
    Junior Member davism's Avatar
    Join Date
    Jan 2004
    Location
    Rotherham, UK
    Posts
    30
    How do I use the NET USER function then because I cannot find it on the internet or Object Explorer.

  5. #5
    start>run>cmd>net user

  6. #6

    Thread Starter
    Junior Member davism's Avatar
    Join Date
    Jan 2004
    Location
    Rotherham, UK
    Posts
    30
    Is there anyway to put them into a listview control. So it would be like network neighborhood.

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    This will find all available domains and the computers in each.
    It populates a combo (cboDomain) with the domains and when
    you click on a domain it will populate another combo
    (cboComputer) with the computers in that domain.

    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


    VB/Outlook Guru!
    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

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    This is also good for selecting computers/folders/files,
    just in case you may like it instead.

    VB Code:
    1. Private Type BrowseInfo
    2.     hWndOwner As Long
    3.     pIDLRoot As Long
    4.     pszDisplayName As Long
    5.     lpszTitle As Long
    6.     ulFlags As Long
    7.     lpfnCallback As Long
    8.     lParam As Long
    9.     iImage As Long
    10. End Type
    11. Private Const BIF_DONTGOBELOWDOMAIN As Long = &H2
    12. Private Const BIF_BROWSEINCLUDEFILES As Long = &H4000
    13. Private Const BIF_BROWSEFORPRINTER As Long = &H2000
    14. Private Const BIF_BROWSEFORCOMPUTER As Long = &H1000
    15. Private Const BIF_RETURNONLYFSDIRS As Long = &H1
    16. Private Const BIF_RETURNFSANCESTORS As Long = &H8
    17. Const MAX_PATH = 260
    18. Private Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)
    19. Private Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
    20. Private Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long
    21. Private Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long
    22. Private Sub Form_Load()
    23.     'KPD-Team 1998
    24.     'URL: [url]http://www.allapi.net/[/url]
    25.     Dim iNull As Integer, lpIDList As Long, lResult As Long
    26.     Dim sPath As String, udtBI As BrowseInfo
    27.  
    28.     With udtBI
    29.         'Set the owner window
    30.         .hWndOwner = Me.hWnd
    31.         'lstrcat appends the two strings and returns the memory address
    32.         .lpszTitle = lstrcat("C:\", "")
    33.         'Return only if the user selected a directory
    34.         .ulFlags = BIF_RETURNONLYFSDIRS
    35.     End With
    36.  
    37.     'Show the 'Browse for folder' dialog
    38.     lpIDList = SHBrowseForFolder(udtBI)
    39.     If lpIDList Then
    40.         sPath = String$(MAX_PATH, 0)
    41.         'Get the path from the IDList
    42.         SHGetPathFromIDList lpIDList, sPath
    43.         'free the block of memory
    44.         CoTaskMemFree lpIDList
    45.         iNull = InStr(sPath, vbNullChar)
    46.         If iNull Then
    47.             sPath = Left$(sPath, iNull - 1)
    48.         End If
    49.     End If
    50.  
    51.     MsgBox sPath
    52. End Sub
    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

  9. #9

    Thread Starter
    Junior Member davism's Avatar
    Join Date
    Jan 2004
    Location
    Rotherham, UK
    Posts
    30
    RobDog888 could you send me a zip file of your code because I get an error message up everytime I try to run it. Something about Private Const in module or something, anyway it would be greatly appreciated. is it possible to make it appear in a tree view.

    Thanx davism

  10. #10
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787
    rob dogs code must be put into a module, and called from your form, it wont work in the form

  11. #11
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787
    just came accross this, hope it will help you


    http://www.developerfusion.com/show/3169/

  12. #12

    Thread Starter
    Junior Member davism's Avatar
    Join Date
    Jan 2004
    Location
    Rotherham, UK
    Posts
    30
    Sorry I haven't replied sooner I've been on hols. I tried all the code you gave me but I get runtime error "48" File not found "Netapi32". So I copied netapi32.dll to the folder of my project and I still get the smae message.

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