|
-
Feb 18th, 2006, 01:22 AM
#1
Thread Starter
Member
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....
-
Feb 18th, 2006, 07:20 AM
#2
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
-
Feb 18th, 2006, 07:38 AM
#3
Re: What is the Code to display connected computers?
Provided you havein your Winsock_Close and Winsock_Error events you should be able to use a timer like the other thread
VB 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."
You could also do it by just updating the onlineusers when a socket is closed and when a new socket is connected
-
Feb 18th, 2006, 09:29 AM
#4
Thread Starter
Member
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
-
Feb 18th, 2006, 11:22 AM
#5
Hyperactive Member
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:
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)
Elseif Button = 1 then
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
-
Feb 22nd, 2006, 11:02 AM
#6
Thread Starter
Member
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...
-
Feb 22nd, 2006, 12:06 PM
#7
Thread Starter
Member
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
-
Feb 22nd, 2006, 06:07 PM
#8
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
-
Feb 24th, 2006, 01:13 AM
#9
Thread Starter
Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|