*/
Got something to write about? Check out our Article Builder.
*/

View client\client.frm

Remote admin tool 1.0

Submitted By: rvhulsel
Rating: (Not rated) (Rate It)


VERSION 5.00
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
Begin VB.Form Form1
   Caption         =   "Client"
   ClientHeight    =   4980
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   6975
   LinkTopic       =   "Form1"
   ScaleHeight     =   4980
   ScaleWidth      =   6975
   StartUpPosition =   3  'Windows Default
   Begin VB.TextBox Commando
      Height          =   285
      Left            =   3120
      TabIndex        =   3
      Text            =   "ping www.altavista.com"
      Top             =   2160
      Width           =   3615
   End
   Begin VB.CommandButton Send
      Caption         =   "Send"
      Height          =   495
      Left            =   4560
      TabIndex        =   2
      Top             =   1320
      Width           =   1695
   End
   Begin VB.Timer TimeOutTimer
      Enabled         =   0   'False
      Left            =   2520
      Top             =   4440
   End
   Begin MSWinsockLib.Winsock Listener
      Left            =   1800
      Top             =   4440
      _ExtentX        =   741
      _ExtentY        =   741
      _Version        =   393216
   End
   Begin MSWinsockLib.Winsock Broadcast
      Left            =   360
      Top             =   4440
      _ExtentX        =   741
      _ExtentY        =   741
      _Version        =   393216
   End
   Begin MSWinsockLib.Winsock Unicast
      Left            =   1080
      Top             =   4440
      _ExtentX        =   741
      _ExtentY        =   741
      _Version        =   393216
   End
   Begin VB.ListBox ValidComputers
      Height          =   3960
      Left            =   360
      MultiSelect     =   2  'Extended
      TabIndex        =   1
      Top             =   360
      Width           =   2175
   End
   Begin VB.CommandButton Refresh
      Caption         =   "Refresh"
      Height          =   495
      Left            =   4560
      TabIndex        =   0
      Top             =   600
      Width           =   1695
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'client
Dim Choosing As Boolean
Dim Turn As Long
Dim ChoosingTurn As Long
Dim Busy As Boolean

Private Sub wait(Naam As Long)
    Do
        Do
            Do Until (Busy = False) And (Choosing = False)
                DoEvents
            Loop
            If (Choosing = False) Then
                Choosing = True
                ChoosingTurn = Naam
                DoEvents
            End If
        Loop While (ChoosingTurn <> Naam) Or Busy
        Busy = True
    Loop While (ChoosingTurn <> Naam)
    Turn = ChoosingTurn
    TimeOutTimer.Enabled = True
End Sub
Private Sub signal()
    TimeOutTimer.Enabled = False
    Choosing = False
    Busy = False
End Sub

Private Sub BroadcastWhoIsThere()
    Dim DataBuffer As String
    Broadcast.RemoteHost = "255.255.255.255"
    'MsgBox Broadcast.LocalIP
    DataBuffer = Broadcast.LocalIP
    Broadcast.SendData DataBuffer
End Sub

Private Sub Form_Load()
    TimeOutTimer.Enabled = False
    TimeOutTimer.Interval = 2000
    Busy = False
    Choosing = False
    ValidComputers.Clear
    Broadcast.Protocol = sckUDPProtocol
    Unicast.Protocol = sckTCPProtocol
    Listener.Protocol = sckTCPProtocol
    Broadcast.LocalPort = 2301
    Broadcast.RemotePort = 2300
    Unicast.RemotePort = 2303
    Listener.LocalPort = 2302
    Listener.Listen
    Broadcast.Bind
    BroadcastWhoIsThere
End Sub

Private Sub Listener_ConnectionRequest(ByVal requestID As Long)
    wait (requestID)
    If Listener.State <> sckClosed Then
        Listener.Close
    End If
    Listener.Accept requestID
End Sub

Private Sub Listener_DataArrival(ByVal bytesTotal As Long)
    Dim DataBuffer As String
    Listener.GetData DataBuffer
    Listener.Close
    Do Until Listener.State = sckClosed
        DoEvents
    Loop
    signal
    Listener.Listen
    ValidComputers.AddItem (DataBuffer)
End Sub

Private Sub Refresh_Click()
    ValidComputers.Clear
    BroadcastWhoIsThere
End Sub
Private Sub SendMessage(Message As String, HostIP As String)
    Unicast.RemoteHost = HostIP
    Unicast.Connect
    Do Until Unicast.State = sckConnected
        DoEvents
    Loop
    Unicast.SendData Message
    Do Until Unicast.State = sckClosed
        DoEvents
    Loop
End Sub

Private Sub Send_Click()
    Dim Teller As Integer
    Dim Current As String
    For Teller = 0 To ValidComputers.ListCount - 1
        If ValidComputers.Selected(Teller) Then
            Current = ValidComputers.List(Teller)
            SendMessage Commando.Text, Current
        End If
    Next
End Sub

Private Sub TimeOutTimer_Timer()
    signal
End Sub

corner
© 1996-2008 CommunityHeaven LLC. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
North American business development: Nicolai Wadstrom. Publisher: Lars Hagelin.