Results 1 to 9 of 9

Thread: What is the Code to display connected computers?

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    61

    Exclamation What is the Code to display connected computers?

    Hi i just join this forum. I'm doing on a project to control the computers in my campus lab. It need to display computers which just on and to display the number of connected computer. The code i have can only display the computers which are connected to the same network as mine if they off their computer then it won't display anymore. I also need to display the computer which are off coz i have to do Wake on LAN on them to wake them up. Please help me....

  2. #2
    Frenzied Member the182guy's Avatar
    Join Date
    Nov 2005
    Location
    Cheshire, UK
    Posts
    1,473

    Re: What is the Code to display connected computers?

    Is this a winsock app and the other computer is connected via sockets? Or is it just a windows Local Area Network and you want to find out about the connected PCs on the LAN?

    If its a winsock app can you please post the entire code for the winsock events
    Last edited by the182guy; Feb 18th, 2006 at 07:33 AM.
    Chris

  3. #3
    Frenzied Member the182guy's Avatar
    Join Date
    Nov 2005
    Location
    Cheshire, UK
    Posts
    1,473

    Re: What is the Code to display connected computers?

    Provided you have
    VB Code:
    1. Winsock1.Close(Index)
    in your Winsock_Close and Winsock_Error events you should be able to use a timer like the other thread
    VB Code:
    1. Dim i as Integer
    2. Dim OnlineUsers as Integer
    3.  
    4. For i = 1 to Winsock1.UBound
    5.      If Winsock1(i).State = sckConnected Then
    6.           OnlineUsers = OnlineUsers + 1
    7.      End If
    8. Next i
    9.  
    10. Label1.Caption = "There are currently: " & OnlineUsers & " computers connected."
    You could also do it by just updating the onlineusers when a socket is closed and when a new socket is connected
    Chris

  4. #4

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    61

    My server coding to connect to client

    Private Sub lstComputers_MouseDown(Button As Integer, Shift As Integer, x As Single, Y As Single)
    Dim i As Integer
    Dim PCName As String
    Dim RemoteHost As String


    If lstComputers.Selected(selectedPC_index) = True Then
    If Button = 2 Then ' if the mousebutton 2 is pressed (right)
    PopupMenu Rclick ' then it calls the menu which is hidden to be shown
    ' at the cordinates of the mousepointer (x,y)

    Else

    Button = 1

    RemoteHost = lstComputers.List(selectedPC_index)
    sckControlPanel.RemoteHost = RemoteHost
    sckControlPanel.RemotePort = 8005
    sckControlPanel.Connect

    End If

    Else
    sckControlPanel.Close
    Call sckControlPanel_Close

    End If

    Data1.Refresh
    End Sub

  5. #5
    Hyperactive Member
    Join Date
    Feb 2006
    Location
    Melbourne, Australia
    Posts
    415

    Re: What is the Code to display connected computers?

    This wont solve your problem, but you need to change your if statements to this:
    VB Code:
    1. Private Sub lstComputers_MouseDown(Button As Integer, Shift As Integer, x As Single, Y As Single)
    2. Dim i As Integer
    3. Dim PCName As String
    4. Dim RemoteHost As String
    5.  
    6.  
    7. If lstComputers.Selected(selectedPC_index) = True Then
    8.  
    9. If Button = 2 Then ' if the mousebutton 2 is pressed (right)
    10. PopupMenu Rclick ' then it calls the menu which is hidden to be shown
    11. ' at the cordinates of the mousepointer (x,y)
    12.  
    13. Elseif Button = 1 then
    14.  
    15. RemoteHost = lstComputers.List(selectedPC_index)
    16. sckControlPanel.RemoteHost = RemoteHost
    17. sckControlPanel.RemotePort = 8005
    18. sckControlPanel.Connect
    19.  
    20. End If
    21.  
    22. Else
    23. sckControlPanel.Close
    24. Call sckControlPanel_Close
    25.  
    26. End If
    27.  
    28. Data1.Refresh
    29. End Sub

  6. #6

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    61

    Talking Thanks alot you guys!!!

    Thanks alot you guys!!! I will look into your suggustions. Thanks alot Hope all of you will have a nice day...

  7. #7

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    61

    What is this??

    visual basic code:--------------------------------------------------------------------------------
    Winsock1.Close(Index)

    What is this??

    When i run this codes

    visual basic code:--------------------------------------------------------------------------------
    Dim i as Integer
    Dim OnlineUsers as Integer

    For i = 1 to Winsock1.UBound
    If Winsock1(i).State = sckConnected Then
    OnlineUsers = OnlineUsers + 1
    End If
    Next i

    Label1.Caption = "There are currently: " & OnlineUsers & " computers connected."
    ---------------------------------------------------------------------------

    It come out compile error method or data not found Please advise me.. I used it like this Private Sub sckControlPanel_Close()
    If sckControlPanel.State <> sckNotConnected Then

    StatusBar1.Panels(1).Text = "Not Connected "

    End If

    Dim i As Integer
    Dim OnlineUsers As Integer

    For i = 1 To sckControlPanel.UBound(ServerList.List)
    If sckControlPanel(i).State = sckConnected Then
    OnlineUsers = OnlineUsers + 1
    End If
    Next i

    Label5.Caption = "There are currently: " & OnlineUsers & " computers connected."

    End Sub

  8. #8
    Frenzied Member the182guy's Avatar
    Join Date
    Nov 2005
    Location
    Cheshire, UK
    Posts
    1,473

    Re: What is the Code to display connected computers?

    If you read my post carefully it tells you to put that in a timer, not the close event, it tells you you need Sock.Close in the close event..........

    I thought you said this was an app which many more than 1 client connect in which case you need a socket array sckControlPanel() but from your code you seem to just have a single socket with no array, one socket can only handle one connection.

    Its giving error because you dont have an array you only have the single socket
    Chris

  9. #9

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    61

    Can you show me how to do that?

    Can you show me how to do a socket array sckControlPanel()? I'm still not that good with this. Yes sorry i miss out the word timer. Can you give me more guide on this matter.. Thanks alot in advance.

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