|
3楼
楼主 |
发表于 2004-5-12 20:15:00
|
只看该作者
Dim PortNo As Long3 [. ]" { _" l
Private Sub Command1_Click()* @) T. I% L Y4 {" N
MsgBox "您的IP地址是:" & Winsock1.LocalIP+ w6 r/ q7 l" C$ ~5 h
End Sub7 y0 \: S1 `4 B) G1 t
Private Sub Command2_Click()% d' A" u* B) i3 u
MsgBox "您的计算机名称是:" & Winsock1.LocalHostName
" K' d. q! P) t; YEnd Sub
' W* }+ L: g4 M1 S8 E& VPrivate Sub Command3_Click()
7 r# j# s5 z& F/ z; t/ nEnd# }+ H( Y- k _, p, ?0 @
End Sub* ]9 R* p. a2 g6 |
Private Sub Command4_Click()7 c$ t, e) @ s# ^
PortNo = CLng(Text2.Text) - 14 ?' ]' N- A% q1 B1 C9 G
Text4.Text = ""
, O1 o- y0 \' B1 C' hCommand5.Enabled = True3 F1 O0 ?" s& ?" G; V F! Q
Command4.Enabled = False
, B" J s0 V" DIf PortNo < 0 Or PortNo > 32767 Then. X! O7 W$ K3 \4 W( X4 W
MsgBox "您的输入错误,端口超过范围"
9 _5 o6 `% T; `7 w3 }7 [0 iCommand5_Click
/ O9 U U( w$ k- R! uExit Sub
1 V9 \' y6 \0 w' n7 ~8 ^Else
4 q# e9 @" v8 G U2 YWinsock1.Connect Text1.Text, PortNo! t- M* g3 W/ G7 s) S7 p& R- K5 ?
Text4.Text = "开始端口扫描......"0 P$ i9 A* h6 b5 R4 r3 ?, J
End If b9 t @, u. p
End Sub
& B3 q9 b8 k' @. v. C2 oPrivate Sub Command5_Click()4 ~3 S$ y3 X/ ]3 Q
Command5.Enabled = False4 P8 w4 S1 T/ M* u
Command4.Enabled = True
# q \$ p5 p' s# ~Winsock1.Close
; c. l& N0 _& q: V! j) @: ? GText4.Text = Text4.Text & vbCrLf & "端口扫描已停止。"
8 C" Q/ [ U2 E' L1 C8 q% vEnd Sub
2 a0 M% X; A W4 E9 XPrivate Sub Command6_Click()
2 [/ |+ ^, F& Z8 H( qMe.Hide9 a( J4 {3 m3 p9 O. ?8 Q: u" p
Form2.Show/ T" u+ {; [* u" o4 j2 K, P
End Sub8 Z6 p$ {: M+ o
Private Sub Command7_Click()
5 \! O3 N2 Q$ Z; hFileName = "d:\ipdetail.txt"+ M5 q5 |' a* k" L
Shell "command.com /c ipconfig.exe >" & FileName, vbHide6 _) h# ^+ F x1 G; T
DoEvents, Y" Z$ ~; T. [( e& q
Do While Trim(Dir(FileName)) = ""
! s6 H. [, L5 p7 C1 }DoEvents8 ]9 }$ O4 U" s# A8 P$ I5 [- T4 [
Loop
! v6 i' ^! N. A9 b# J l8 UDim strstring As String, FileNo" L3 x( T5 i3 |% E
Dim sVar( B8 K8 X+ d5 K! D# T
If Winsock1.LocalPort = 0 Then
8 C8 k" C6 k+ W" D4 x; Z2 fstrstring = "端口编号未设置!"
1 ]) c" k) Y8 l* O! YElse9 ~. `6 ]2 ?; p0 N. r, m6 i$ Q' a
strstring = Winsock1.LocalPort! d" ^# I2 Y4 E0 C1 L: q, w3 a
End If' y9 N2 C! A; h' z" \
Text5.Text = "您的主机名称为:" & Winsock1.LocalHostName & vbCrLf
/ k* p- b7 b% y" b1 eText5.Text = Text5.Text & "连接端口为:" & strstring & vbCrLf
, X# J$ t1 Q2 H2 T4 `/ r. HText5.Text = Text5.Text & "通信协议为:" & IIf(Winsock1.Protocol = 0, "TCP协议", "UDP协议")
" O% A+ d2 K- ]; |FileNo = FreeFile()
O( z' ], [# O$ M% ~' UOpen FileName For Input As #FileNo& R5 N0 d' W w+ i
While Not EOF(FileNo)
! S( C. G+ Y$ [! e, t8 S3 kLine Input #FileNo, sVar
4 P$ ~# ?3 S" [& S- mText5.Text = Text5.Text & sVar & vbCrLf
5 F' z0 o) S) p3 S( \Wend
, R/ J% m4 \8 W! h6 J; `Close #FileNo; ?# N# |- L" \) W9 `7 Y
MsgBox Text5.Text, [7 J3 P5 w: t4 V
End Sub7 A+ E9 ]5 `* ?) Y3 ^" }0 x
Private Sub Command8_Click()3 u; z0 L% G; k- z! J7 n3 `7 ^
MsgBox "考拉制作!"; A& X. v U/ [+ W* \$ O
End Sub
/ z0 u m! t% y! xPrivate Sub Winsock1_Connect()8 y3 K) ?. V5 g3 M1 R
Text4.Text = Text4.Text & "连接端口号:" & Str(Winsock1.RemotePort) & vbCrLf
' K5 U1 x. }7 V* VWinsock1.Close
- m% A3 ^/ z1 O; a- v( RPortNo = PortNo + 18 q6 |1 i! X7 ^8 R) F" E
If PortNo <= CLng(Text3.Text) Then: ?- \* f9 W b4 I; f7 p
Text4.Text = Text4.Text & vbCrLf & "已连接端口:" & PortNo
% q: U) p* R- l/ nElse, t' {& o- |$ O! P( o8 L$ m) L
Command5_Click, M: @( I6 t9 T8 u
End If
9 T" k2 t* B! @ iEnd Sub' `' j. F1 q) q6 P, j* E
Private Sub Winsock1_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)) p4 P% ^! j& {/ N( A
Winsock1.Close
1 I7 @! f$ g+ |0 j) ePortNo = PortNo + 1( v, a9 w* @8 f6 \7 }9 D
If PortNo <= CLng(Text3.Text) Then
7 ?& [/ d# t S$ m' p' L2 N& FText4.Text = Text4.Text & vbCrLf & "未连接端口:" & PortNo$ C) a: g( q+ |, G) K
Winsock1.Connect Text1.Text, PortNo4 H. [+ u3 E3 b8 V
Else; Z. ` o( n P1 K
Command5_Click1 e6 a, G! ?6 k, o
End If: p" M2 D9 m$ [7 `/ Y
End Sub
( B+ Q5 N/ H" Y9 A1 [1 ]3 {) t$ I+ \
Private Sub Command1_Click()
/ `& b8 \% U9 ?1 ^7 V8 TWinsock1.Protocol = sckUDPProtocol
# `' l6 S# I* x* T% yWinsock1.RemoteHost = Text1.Text8 I: U d7 ]2 ~/ ?/ Z
Winsock1.LocalPort = CLng(Text2.Text)5 ^ T# T8 V) Z
Winsock1.RemotePort = CLng(Text3.Text)2 {* I8 n3 E6 z* z8 C( A+ n
Winsock1.Bind
+ K0 E% W- R, w& RCommand1.Enabled = False1 R. Z& S; D, s! g6 O
Command2.Enabled = True
& k7 \, e# S e7 o: F3 N$ H- GEnd Sub
/ C* `! @ V! E3 M2 dPrivate Sub Command2_Click()
% V/ p9 u0 b4 J8 z% HOn Error GoTo ConnectError* p) b% H' B: k9 q M( t( H# X4 H, _
Winsock1.SendData "Koala:" & Text5.Text
% Y- i' }! b3 ?4 b) dText4.Text = "Koala:" & Text5.Text & vbCrLf & Text4.Text
' _0 ?* E0 W1 f& |( b1 wText5.Text = ""/ v1 y1 _7 I& Z; N0 X
Exit Sub
. p2 P% W* n8 `: ]* K: u, eConnectError:/ g5 Y8 Y# ], @4 o- Q* P, N* t
MsgBox Error_message
2 s3 T: r9 B8 P1 WEnd Sub
; U0 N( h' U( V- M$ RPrivate Sub Command3_Click()
# ~& J$ r+ w- V4 pMe.Hide
: d& y. }, g! l8 D1 l9 oForm1.Show5 x+ o% d. p! d; v, Z
End Sub, f; T, Z3 Q2 y' N) p5 V
Private Sub Command4_Click()
0 W) ^) d' p# H% N+ h3 \6 L6 oEnd
8 T; C) k& ]$ o- IEnd Sub
0 A" d' M4 I1 R) E4 m6 cPrivate Sub Text5_KeyPress(KeyAscii As Integer)
8 \9 H! n! t3 K- u0 iIf KeyAscii = 13 Then
* l4 n& s9 j6 [/ l7 QCommand2_Click
- e) X& b! I) N( E# ^End If2 ~- h l; A4 v
End Sub6 c. y) A5 ~! m' D X: m3 s
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
& W! O! X" O7 ]& K; I mDim sVar As String
+ x ]- q w8 F( d" N5 `! nWinsock1.GetData sVar, vbString
* N* h5 R# C. N' y. ~; a* MText4.Text = sVar & vbCrLf & Text4.Text. \- f6 g& o7 A! b3 u3 x$ ]# S
End Sub/ ~! I1 Q, ~6 x7 Y
, y- ~0 w/ c+ ?' g+ I6 X. }% f" t: c2 x% h4 n p) C. \
. F6 ?) p/ V9 A
) b8 k/ r' k( X7 F; n; d( Y
" ^8 g. ^. ?8 z2 H7 |% e( }
[此贴子已经被作者于2004-5-12 20:16:53编辑过] ; r* T+ H6 E1 b: X( S
|
|