📄 telnet.frm
字号:
VERSION 5.00
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "COMCTL32.OCX"
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
Begin VB.Form frmTelnet
BackColor = &H80000017&
BorderStyle = 3 'Fixed Dialog
Caption = "Ian's Telnet Client"
ClientHeight = 5970
ClientLeft = -225
ClientTop = 3000
ClientWidth = 8220
FillColor = &H00800000&
BeginProperty Font
Name = "Fixedsys"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H0000FFFF&
Icon = "telnet.frx":0000
KeyPreview = -1 'True
LinkTopic = "Form1"
MaxButton = 0 'False
PaletteMode = 1 'UseZOrder
ScaleHeight = 5970
ScaleWidth = 8220
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin MSWinsockLib.Winsock WinsockClient
Left = 6120
Top = 600
_ExtentX = 741
_ExtentY = 741
_Version = 393216
End
Begin VB.Timer cursor_timer
Enabled = 0 'False
Interval = 300
Left = 6600
Top = 600
End
Begin ComctlLib.StatusBar stbStatusBar
Align = 2 'Align Bottom
Height = 495
Left = 0
TabIndex = 0
Top = 5475
Width = 8220
_ExtentX = 14499
_ExtentY = 873
SimpleText = ""
_Version = 327682
BeginProperty Panels {0713E89E-850A-101B-AFC0-4210102A8DA7}
NumPanels = 4
BeginProperty Panel1 {0713E89F-850A-101B-AFC0-4210102A8DA7}
Object.Width = 2822
MinWidth = 2822
Text = "No Connection"
TextSave = "No Connection"
Key = "Mode"
Object.Tag = ""
Object.ToolTipText = "Operating Mode"
EndProperty
BeginProperty Panel2 {0713E89F-850A-101B-AFC0-4210102A8DA7}
Text = "None"
TextSave = "None"
Key = "Lip"
Object.Tag = ""
Object.ToolTipText = "Local IP"
EndProperty
BeginProperty Panel3 {0713E89F-850A-101B-AFC0-4210102A8DA7}
Text = "None"
TextSave = "None"
Key = "Rip"
Object.Tag = ""
Object.ToolTipText = "Remote IP"
EndProperty
BeginProperty Panel4 {0713E89F-850A-101B-AFC0-4210102A8DA7}
AutoSize = 1
Object.Width = 6456
Text = "Welcome to Ian's Telnet Client"
TextSave = "Welcome to Ian's Telnet Client"
Key = "Status"
Object.Tag = ""
Object.ToolTipText = "Last Status Message"
EndProperty
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin VB.Menu mFile
Caption = "File"
Begin VB.Menu mExit
Caption = "Exit"
End
End
Begin VB.Menu mConnection
Caption = "Connection"
Begin VB.Menu mSettings
Caption = "Settings"
End
Begin VB.Menu mOpen
Caption = "Open"
End
Begin VB.Menu mClose
Caption = "Close"
End
End
End
Attribute VB_Name = "frmTelnet"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Const GO_NORM = 0
Const GO_ESC1 = 1
Const GO_ESC2 = 2
Const GO_ESC3 = 3
Const GO_ESC4 = 4
Const GO_ESC5 = 5
Const GO_IAC1 = 6
Const GO_IAC2 = 7
Const GO_IAC3 = 8
Const GO_IAC4 = 9
Const GO_IAC5 = 10
Const GO_IAC6 = 11
Const SUSP = 237
Const ABORT = 238 'Abort
Const SE = 240 'End of Subnegotiation
Const NOP = 241
Const DM = 242 'Data Mark
Const BREAK = 243 'BREAK
Const IP = 244 'Interrupt Process
Const AO = 245 'Abort Output
Const AYT = 246 'Are you there
Const EC = 247 'Erase character
Const EL = 248 'Erase Line
Const GOAHEAD = 249 'Go Ahead
Const SB = 250 'What follows is subnegotiation
Const WILLTEL = 251
Const WONTTEL = 252
Const DOTEL = 253
Const DONTTEL = 254
Const IAC = 255
Const BINARY = 0
Const ECHO = 1
Const RECONNECT = 2
Const SGA = 3
Const AMSN = 4
Const STATUS = 5
Const TIMING = 6
Const RCTAN = 7
Const OLW = 8
Const OPS = 9
Const OCRD = 10
Const OHTS = 11
Const OHTD = 12
Const OFFD = 13
Const OVTS = 14
Const OVTD = 15
Const OLFD = 16
Const XASCII = 17
Const LOGOUT = 18
Const BYTEM = 19
Const DET = 20
Const SUPDUP = 21
Const SUPDUPOUT = 22
Const SENDLOC = 23
Const TERMTYPE = 24
Const EOR = 25
Const TACACSUID = 26
Const OUTPUTMARK = 27
Const TERMLOCNUM = 28
Const REGIME3270 = 29
Const X3PAD = 30
Const NAWS = 31
Const TERMSPEED = 32
Const TFLOWCNTRL = 33
Const LINEMODE = 34
Const DISPLOC = 35
Const ENVIRON = 36
Const AUTHENTICATION = 37
Const UNKNOWN39 = 39
Const EXTENDED_OPTIONS_LIST = 255
Const RANDOM_LOSE = 256
'------------------------------------------------------------
Private Operating As Boolean
Private Connected As Boolean
Public Receiving As Boolean
Private parsedata(10) As Integer
Private ppno As Integer
Private control_on As Boolean
Public RemoteIPAd As String
Public RemotePort As Integer
Public TraceTelnet As Boolean
Public Tracevt100 As Boolean
Private sw_ugoahead As Boolean
Private sw_igoahead As Boolean
Private sw_echo As Boolean
Private sw_linemode As Boolean
Private sw_termsent As Boolean
Private substate As Boolean
Private Sub cursor_timer_Timer()
If Not Receiving Then
' Debug.Print "Timer"
term_DriveCursor
End If
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Dim CH As String
CH = Chr$(0)
'Translate keycodes to VT100 escape sequences
Select Case KeyCode
Case vbKeyControl
control_on = True
Case vbKeyEnd
CH = Chr$(27) + "[K"
Case vbKeyHome
CH = Chr$(27) + "[H"
Case vbKeyLeft
CH = Chr$(27) + "[D"
Case vbKeyUp
CH = Chr$(27) + "[A"
Case vbKeyRight
CH = Chr$(27) + "[C"
Case vbKeyDown
CH = Chr$(27) + "[B"
Case vbKeyF1
CH = Chr$(27) + "OP"
Case vbKeyF2
CH = Chr$(27) + "OQ"
Case vbKeyF3
CH = Chr$(27) + "OR"
Case vbKeyF4
CH = Chr$(27) + "OS"
Case Else
If control_on And KeyCode > 63 Then
CH = Chr$(KeyCode - 64)
End If
End Select
If CH > Chr$(0) And Connected Then
WinsockClient.SendData CH
If TraceTelnet Then Debug.Print CH
End If
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
Dim CH As String
If Connected Then
CH = Chr$(KeyAscii)
If control_on Then
If KeyAscii > 63 Then
CH = Chr$(KeyAscii - 64)
Else
CH = Chr$(0)
End If
End If
If CH > Chr$(0) Then
If CH = Chr$(13) Then
CH = CH & Chr$(10)
End If
WinsockClient.SendData CH
End If
End If
End Sub
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyControl
control_on = False
End Select
End Sub
Private Sub Form_Load()
RemoteIPAd = "fastlane.net"
RemotePort = 23
stbStatusBar.Panels(2).Text = WinsockClient.LocalIP
term_init
End Sub
Private Sub Form_Paint()
term_redrawscreen
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
With WinsockClient
.Close ' Clear any errors...
.RemoteHost = "0.0.0.0"
.RemotePort = 0
End With
Operating = False
Connected = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
End ' End program forcefully
End Sub
Private Sub mClose_Click()
WinsockClient_Close
End Sub
Private Sub mExit_Click()
End
End Sub
Private Sub mOpen_Click()
On Error Resume Next ' Handle errors...
'------------------------------------------------------------
If Not Operating Then
Operating = True
If TraceTelnet Then Debug.Print Int(Timer) & " - [DoConnect] : " & vbCrLf
With WinsockClient
If .State <> 0 Then
.Close
.RemotePort = 0
.LocalPort = 0
Do
Loop Until .State = 0
End If
.RemoteHost = RemoteIPAd
.RemotePort = RemotePort
.Connect ' Attempt new connection
term_init
frmTelnet.stbStatusBar.Panels(4).Text = "Connecting to Remote Host"
End With
End If
End Sub
Private Sub mSettings_Click()
frmTCPIP.Show vbModal, frmTelnet
End Sub
Private Sub WinsockClient_Close()
frmTelnet.stbStatusBar.Panels(1).Text = "Closed"
frmTelnet.stbStatusBar.Panels(3).Text = WinsockClient.LocalIP
frmTelnet.stbStatusBar.Panels(2).Text = ""
frmTelnet.stbStatusBar.Panels(4).Text = "Connection Reset"
If TraceTelnet Then Debug.Print Int(Timer) & " - [Closed ] : Connection Reset By Peer "
With WinsockClient
.Close ' Clear any errors...
.RemotePort = 0
.LocalPort = 0
End With
Operating = False
Connected = False
End Sub
Private Sub WinsockClient_Connect()
Dim ConnectString As String
'------------------------------------------------------------
If TraceTelnet Then Debug.Print Int(Timer) & " - [Connect] : " & _
"[" & WinsockClient.RemoteHost & "] " & _
"[" & WinsockClient.RemoteHostIP & "] " & _
"[" & CStr(WinsockClient.RemotePort) & "]" ' Display connection info
sw_ugoahead = True
sw_igoahead = False
sw_echo = True
sw_linemode = False
sw_termsent = False
substate = False
ConnectString = Chr$(IAC) & Chr$(DOTEL) & Chr$(ECHO) _
& Chr$(IAC) & Chr$(DOTEL) & Chr$(SGA) _
& Chr$(IAC) & Chr$(WILLTEL) & Chr$(NAWS) _
& Chr$(IAC) & Chr$(WILLTEL) & Chr$(TERMTYPE) _
& Chr$(IAC) & Chr$(WILLTEL) & Chr$(TERMSPEED)
WinsockClient.SendData ConnectString
If TraceTelnet Then Debug.Print "SENT: DOTEL ECHO SGA"
If TraceTelnet Then Debug.Print "SENT: WILL NAWS TERMTYPE TERMSPEED"
Connected = True
frmTelnet.stbStatusBar.Panels(1).Text = "Connected"
frmTelnet.stbStatusBar.Panels(3).Text = WinsockClient.LocalIP
frmTelnet.stbStatusBar.Panels(2).Text = WinsockClient.RemoteHostIP
frmTelnet.stbStatusBar.Panels(4).Text = "Connection Accepted By Remote Host"
End Sub
Private Sub WinsockClient_DataArrival(ByVal bytesTotal As Long)
Dim CH() As Byte
Dim Test() As Integer
Dim I As Integer
Static cmd As Byte
'------------------------------------------------------------
If Not Receiving Then
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -