Results 1 to 28 of 28

Thread: Is 'X' computer on the network?

  1. #1

    Thread Starter
    Member Swishy's Avatar
    Join Date
    Feb 2003
    Location
    Huntsville, AL
    Posts
    39

    Is 'X' computer on the network?

    Hey, all. I'm trying to write a program that can 'peek' at the network neighborhood and tell me if a certain computer (its NetBIOS name, I mean) is showing up on the network. In other words, is the thing up and running?

    I've thought of two methods. One is to do what I said -- scan the list periodically, refreshing as necessary.

    The other is to map a drive to that computer's hard drive, and just see if the program can access the drive.

    Which would be easier? I have two considerations:

    The computer that would be scanning is on a different network than the one it would be looking for. That is, this computer is a 192.* computer, the other is a 10.*. That's why I think it might be easier to map a drive...

    If I map a drive, though, how do I get it to not time out and crash this computer in case it can't access it?

    Any ideas?

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Couldn't you ping the computer since you know the ip address?
    You can have allot of code to do ping in vb or you could
    shellexecute the cmd.exe with the parameters already filled in
    and pipe the results out to a text file. Then read the text file and
    see the results.

    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
    4. (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, _
    5. ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
    6.  
    7. Private Const SW_SHOWNORMAL As Long = 1
    8. Private Const SW_HIDE As Long = 0
    9. Private Const SW_SHOWMINNOACTIVE As Long = 7
    10.  
    11. Private Sub Command1_Click()
    12.     Dim lRet as Long
    13.     lRet = ShellExecute(Me.Hwnd, "OPEN", "C:\WINNT\system32\CMD.exe", "/C Ping 192.168.100.1 > C:\PingResults.txt", "C:\", SW_SHOWNORMAL)
    14. 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

  3. #3
    Addicted Member
    Join Date
    Mar 2004
    Posts
    146
    You may want to try searching for the "PathIsNetworkPath" function so you can check to see if a certain network path exists. Just a thought.

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    The PathIsNetworkPath API only does a string character eveluation
    of the path provided. It does not check for the validity of the
    resource. Test it out. This line from the example at allapi.net will
    confirm it to you. When testing \\Server\C$... it comes up as
    true for a network path even though my computer is not
    named "Server". All it looks for is the double backslashes.

    VB Code:
    1. Me.Print "Is the specified path a network path? " + CStr(CBool(PathIsNetworkPath("\\Server\C$\test.txt")))
    Sorry but it doesnt work for what the poster wants.
    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

  5. #5

    Thread Starter
    Member Swishy's Avatar
    Join Date
    Feb 2003
    Location
    Huntsville, AL
    Posts
    39
    No, since they're on two networks without a bridge. I can't ping between the two networks despite the fact I can share files and folders...

    Originally posted by RobDog888
    Couldn't you ping the computer since you know the ip address?
    You can have allot of code to do ping in vb or you could
    shellexecute the cmd.exe with the parameters already filled in
    and pipe the results out to a text file. Then read the text file and
    see the results.

    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
    4. (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, _
    5. ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
    6.  
    7. Private Const SW_SHOWNORMAL As Long = 1
    8. Private Const SW_HIDE As Long = 0
    9. Private Const SW_SHOWMINNOACTIVE As Long = 7
    10.  
    11. Private Sub Command1_Click()
    12.     Dim lRet as Long
    13.     lRet = ShellExecute(Me.Hwnd, "OPEN", "C:\WINNT\system32\CMD.exe", "/C Ping 192.168.100.1 > C:\PingResults.txt", "C:\", SW_SHOWNORMAL)
    14. End Sub

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    This code will simulate Network Neighborhood using two combos.
    One for the Active Domains and another for the Active Computers
    in the selected Domain combo. Maybe it will help you get closer to
    a solution.

    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/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

  7. #7
    Addicted Member
    Join Date
    Feb 2008
    Location
    XP & Vista
    Posts
    181

    Re: Is 'X' computer on the network?

    Quote Originally Posted by RobDog888
    This code will simulate Network Neighborhood using two combos.
    One for the Active Domains and another for the Active Computers
    in the selected Domain combo. Maybe it will help you get closer to
    a solution.

    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
    While running i am getting " 424 - object required error message" How can i fix that....

  8. #8
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Is 'X' computer on the network?

    On what line do you encounter the error?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  9. #9
    Addicted Member
    Join Date
    Feb 2008
    Location
    XP & Vista
    Posts
    181

    Re: Is 'X' computer on the network?

    Quote Originally Posted by dee-u
    On what line do you encounter the error?
    on cboDomain_Click() err.number 9....

    Code:
    No_Bugs:
        If Err.Number = "9" Then
            cboDomain.RemoveItem (cboDomain.ListIndex)
            cboDomain.ListIndex = 0
            compNames = GetServers(cboDomain.Text, SV_TYPE_ALL)
            Resume
        Else
            MsgBox Err.Number & " - " & Err.Description & "   " & Err.Source, vbOKOnly + vbExclamation, App.ProductName
        End If
    For above else part executed and giving the 424 object required message.....

  10. #10
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Is 'X' computer on the network?

    Do you have comboboxes in your form named cboDomain and cboComputer?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  11. #11
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Is 'X' computer on the network?

    Are you on a network or a workgroup?
    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

  12. #12
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: Is 'X' computer on the network?

    Basically you need a result back from a NetBIOS computer by name that tells you if it is online and its Server service is running I guess. There are lots of ways to go about this, but I don't see an obvious best choice.

    One is to ask the machine what Domain/Workgroup it belongs to (if any). A non-reply should tell you what you need to know I suppose.
    Code:
    Option Explicit
    
    Private Const NERR_SUCCESS As Long = 0
    
    Public Enum NETSETUP_JOIN_STATUS
        NetSetupUnknownStatus = 0
        NetSetupUnjoined
        NetSetupWorkgroupName
        NetSetupDomainName
    End Enum
    
    Private Declare Function NetApiBufferFree Lib "netapi32" ( _
        ByVal lpBuffer As Long) As Long
    
    Private Declare Function NetGetJoinInformation Lib "netapi32" ( _
        ByRef lpServer As Byte, _
        ByRef lpNameBuffer As Long, _
        ByRef BufferType As NETSETUP_JOIN_STATUS) As Long
    
    Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
        ByVal pTo As Long, _
        ByVal uFrom As Long, _
        ByVal lSize As Long)
        
    Private Declare Function lstrlen Lib "kernel32" Alias "lstrlenW" ( _
        ByVal lpString As Long) As Long
        
    Public Function GetJoinInfo( _
        ByVal Server As String, _
        ByRef Domain As String, _
        ByRef BufferType As NETSETUP_JOIN_STATUS) As Boolean
        'Find Domain or Workgroup name of Server.  Empty Server means "self."
        'Returns True on failure.
        
        Dim bytServer() As Byte
        Dim lngBufPtr As Long
        Dim lngLen As Long
        
        bytServer = Trim$(Server) & vbNullChar
        If NetGetJoinInformation(bytServer(0), lngBufPtr, BufferType) = NERR_SUCCESS Then
            lngLen = lstrlen(lngBufPtr)
            Domain = String$(lngLen, 0)
            CopyMemory StrPtr(Domain), lngBufPtr, lngLen * 2
            NetApiBufferFree lngBufPtr
        Else
            GetJoinInfo = True
        End If
    End Function
    You'll probably only care about the reply status (or error result) and not the returned "domain" name.

    Just one more idea.
    Attached Files Attached Files

  13. #13
    Addicted Member
    Join Date
    Feb 2008
    Location
    XP & Vista
    Posts
    181

    Re: Is 'X' computer on the network?

    I am on workgroup with three computers(currently) connected via the five pin switch. I need to know how many computers are connected to my network at runtime using vb..... Guys thanks for your reply......

  14. #14
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Is 'X' computer on the network?

    What's your answer to post #10?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  15. #15
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: Is 'X' computer on the network?

    Quote Originally Posted by kpmsivachand
    I need to know how many computers are connected to my network at runtime using vb.
    Well ignore my example then. I thought you asked how to test if a single given machine (by name) was reachable.

    Sorry.

  16. #16
    Addicted Member
    Join Date
    Feb 2008
    Location
    XP & Vista
    Posts
    181

    Re: Is 'X' computer on the network?

    Quote Originally Posted by dilettante
    Well ignore my example then. I thought you asked how to test if a single given machine (by name) was reachable.

    Sorry.
    No problem dilettante.... it was useful for finding network work...

  17. #17
    Addicted Member
    Join Date
    Feb 2008
    Location
    XP & Vista
    Posts
    181

    Re: Is 'X' computer on the network?

    Quote Originally Posted by dee-u
    What's your answer to post #10?
    Ya i made two combo boxes dude

  18. #18
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Is 'X' computer on the network?

    Its probably because its looking for a Domain and being in a Workgroup isnt the same thing. You can add error handling for the domain search part like so...

    Code:
    Option Explicit
    
    'BEHIND A FORM WITH TWO COMBOS (cboDomain AND cboComputer)
    Private Sub Form_Load()
    
        On Error GoTo MyError
        
        Dim compNames() As String
        Dim x As Integer
    
        'SETUP THE DOMAIN COMBO BOX
        compNames = GetServers(vbNullString, SV_TYPE_DOMAIN_ENUM)
        If UBound(compNames) >= 0 Then
            For x = LBound(compNames) To UBound(compNames) - 1
                cboDomain.AddItem compNames(x)
            Next
            cboDomain.ListIndex = 0
        End If
        Exit Sub
        
    MyError:
        If Err.Number = 9 Then
            MsgBox "No Domains Found", vbOKOnly + vbExclamation, "Error"
        Else
            MsgBox Err.Number & " - " & Err.Description, vbOKOnly + vbExclamation, "Error"
        End If
    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

  19. #19
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Is 'X' computer on the network?

    Here is the cause of teh 6118 error message value...

    The NetServerEnum function depends on the browser service being installed and running. If no browser servers are found, then NetServerEnum fails with ERROR_NO_BROWSER_SERVERS_FOUND.
    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

  20. #20
    Addicted Member
    Join Date
    Feb 2008
    Location
    XP & Vista
    Posts
    181

    Re: Is 'X' computer on the network?

    Thanks.... I can try it....

  21. #21
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Is 'X' computer on the network?

    Weird, I was only running my Vista system and it didnt find my workgroup but when I started up my XP system it found the Workgroup and both systems.

    Perhaps the system that created the workgroup needs to be running??? More testing under way
    Attached Images Attached Images  
    Last edited by RobDog888; Dec 21st, 2008 at 02:55 PM.
    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

  22. #22
    Addicted Member
    Join Date
    Feb 2008
    Location
    XP & Vista
    Posts
    181

    Re: Is 'X' computer on the network?

    Quote Originally Posted by RobDog888
    Weird, I was only running my Vista system and it didnt find my workgroup but when I started up my XP system it found the Workgroup and both systems.

    Perhaps the system that created the workgroup needs to be running??? More testing under way
    I am using vista only, my workgroup systems are xp sp1 and sp3.

  23. #23
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Is 'X' computer on the network?

    So whihc system is the one where you originally created the workgroup?

    xp sp1 and sp3???
    3 systems or are those service packs?
    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

  24. #24
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Is 'X' computer on the network?

    Perhaps he meant that the computers in his workgroup have those service packs?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  25. #25
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Is 'X' computer on the network?

    This should get you past the rest
    Code:
    Private Sub cboDomain_Click()
        'NEED TO CLEAR CBOCOMPUTER AND RELOAD WITH COMPUTERS IN THE NEWLY SELECTED DOMAIN
        'SETUP THE COMPUTER COMBO BOX
        On Error GoTo No_Bugs
        
        Dim compNames() As String
        Dim x As Integer
        
        cboComputer.Clear
        x = 0
        compNames = GetServers(IIf(cboDomain.Text = vbNullString, vbNull, cboDomain.Text), SV_TYPE_ALL)
        If UBound(compNames) > 0 Then
            For x = LBound(compNames) To UBound(compNames) - 1
                cboComputer.AddItem compNames(x)
            Next
            cboComputer.ListIndex = 0
        End If
        Exit Sub
        
    No_Bugs:
        If Err.Number = "9" Then
            If cboDomain.ListCount > 0 Then
                cboDomain.RemoveItem (cboDomain.ListIndex)
                cboDomain.ListIndex = 0
            End If
            compNames = GetServers(cboDomain.Text, SV_TYPE_ALL)
            Resume
        Else
            MsgBox Err.Number & " - " & Err.Description, vbOKOnly + vbExclamation, App.ProductName
        End If
        
    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

  26. #26
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: Is 'X' computer on the network?

    Another way to get the Network Neighborhood for the current Workgroup/Domain is:
    Code:
    Option Explicit
    'Ref to: Microsoft Shell Controls and Automation.
    
    Private Sub ListHosts(ByVal TextBox As TextBox)
        Dim Shell As Shell32.Shell
        Dim fldNetHood As Shell32.Folder
        Dim itmHost As Shell32.FolderItem
        
        Set Shell = New Shell32.Shell
        With TextBox
            .Text = "Retrieving Network Neighborhood..."
            .Refresh
            Set fldNetHood = Shell.NameSpace(ssfNETWORK)
            .Text = ""
            For Each itmHost In fldNetHood.Items
                .SelStart = Len(.Text)
                .SelText = itmHost.Name & vbNewLine
            Next
        End With
    End Sub
    
    Private Sub Form_Load()
        Show
        ListHosts Text1
    End Sub
    
    Private Sub Form_Resize()
        If WindowState <> vbMinimized Then
            Text1.Move 0, 0, ScaleWidth, ScaleHeight
        End If
    End Sub
    This might be simpler for anyone just interested in machines on a home LAN, which are typically in the same Workgroup.

  27. #27
    Addicted Member
    Join Date
    Feb 2008
    Location
    XP & Vista
    Posts
    181

    Resolved Re: Is 'X' computer on the network?

    First i tried in xp sp3(not worked) then finally test with xp sp1 and vista now working fine... thanks RobDog888 & dee-u.....

  28. #28
    Addicted Member
    Join Date
    Feb 2008
    Location
    XP & Vista
    Posts
    181

    Thumbs up Re: Is 'X' computer on the network?

    Quote Originally Posted by dilettante
    Another way to get the Network Neighborhood for the current Workgroup/Domain is:
    Code:
    Option Explicit
    'Ref to: Microsoft Shell Controls and Automation.
    This might be simpler for anyone just interested in machines on a home LAN, which are typically in the same Workgroup.
    Code looks cool... thanks for the code let me try out tomorrow.... ( Local time: 2:15 AM )

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