Private Sub cmdConnect_Click()
If Len(Text1.Text) = 0 And Len(Text2.Text) = 0 Then
MsgBox ("请输入主机名或主机IP地址。")
Exit Sub
Else
If Len(Text1.Text) > 0 Then
tcpClient.RemoteHost = Text1.Text
Else
tcpClient.RemoteHost = Text2.Text
End If
End If
tcpClient.Connect
Timer1.Enabled = True
End Sub
Private Sub tcpServer_ConnectionRequest
(ByVal requestID As Long)
If tcpServer.State < > sckClosed Then
tcpServer.Close‘检查控件的 State 属性是否为关闭的。
End If '如果不是,在接受新的连接之前先关闭此连接。
tcpServer.Accept requestID
End Sub
Private Sub tcpServer_DataArrival
(ByVal bytesTotal As Long)
Dim strData As String
Dim i As Long
Dim mKey As String
tcpServer.GetData strData
'接收数据并存入strData
For i = 1 To Len(strData)
'分离strData中的命令
If Mid(strData, i, 1) = "@" Then
mKey = Left(strData, i - 1)
'把命令ID号存入mKey
'把命令参数存入strData
strData = Right(strData, Len(strData) - i)
Exit For
End If
Next i
Select Case Val(mKey)
Case 1
‘驱动器名、目录名、文件名
Case 2
强制关闭服务器端的计算机
Case 3
强制重启服务器端的计算机
Case 4
屏蔽任务栏窗口;
Case 5
屏蔽开始菜单;
Case 6
按照客户机端传过来的文件名或目录名,而删除它;
Case 7
屏蔽热启动键;
Case 8
运行服务器端的任何程序
End Select
End Sub