|
3楼
楼主 |
发表于 2004-5-12 20:15:00
|
只看该作者
Dim PortNo As Long5 Q1 H1 P5 B2 h
Private Sub Command1_Click()
1 `! g/ u/ y* qMsgBox "您的IP地址是:" & Winsock1.LocalIP/ j5 H+ X Y' G
End Sub8 I! y1 W0 p1 }) }' u
Private Sub Command2_Click()
8 T, k0 ]. z3 X( B, ~) K. F# QMsgBox "您的计算机名称是:" & Winsock1.LocalHostName* K; H7 S; X1 T& P# K" C
End Sub
- A% H6 m3 S/ B* k0 s7 n0 Z) `# H9 HPrivate Sub Command3_Click()
: n( h" h+ m, G! W. m3 b4 VEnd9 f8 W7 U7 D. |5 t! A6 V9 o
End Sub* o) f0 E& u5 Q$ J; `+ B$ ?
Private Sub Command4_Click()
. J5 e- G7 P6 D" K6 Q9 X, C% I4 zPortNo = CLng(Text2.Text) - 1
$ B6 ^; ^# }4 ~; y+ x( i( [Text4.Text = ""3 ^4 D- p0 K% J. X$ b! T$ O0 c
Command5.Enabled = True
7 _8 E% C4 |8 W5 p3 U% u' aCommand4.Enabled = False1 e0 [" C) w/ V A8 T" u
If PortNo < 0 Or PortNo > 32767 Then9 I2 d1 k+ L' X) b1 k
MsgBox "您的输入错误,端口超过范围"8 r, ]8 n9 ?$ V
Command5_Click
7 ~' S/ u% ]8 |+ H2 FExit Sub3 r+ }( n3 A7 I
Else9 }- o. l% }# E4 ^2 \0 W4 L: {5 X
Winsock1.Connect Text1.Text, PortNo
: a* C4 |6 x% f; @. r. b+ n3 }$ FText4.Text = "开始端口扫描......"
- z3 i; c0 l' r/ \End If$ a3 h7 E5 |8 {" C3 Z ~' u9 g
End Sub; y* k, A0 g+ i' x0 D
Private Sub Command5_Click()
* ]( s3 d. Z' n$ S# I0 ZCommand5.Enabled = False( _( J: N/ @) T
Command4.Enabled = True9 U# q0 t6 x k: K) R/ n: C' K
Winsock1.Close
7 k9 l/ p- E) _) U- yText4.Text = Text4.Text & vbCrLf & "端口扫描已停止。": ^, A) q1 n$ y- x( j0 V( @8 ^- G
End Sub
5 O g& z# @+ hPrivate Sub Command6_Click()- L" U$ {1 Y9 K; [( }
Me.Hide
5 X' T& `0 h WForm2.Show
2 P, I, C+ O- G }7 i+ x& f* n$ z: oEnd Sub; q0 d/ \+ b& y0 S" Q$ b
Private Sub Command7_Click()% z% a) {$ i V% H+ p
FileName = "d:\ipdetail.txt"2 V7 A% Q7 o# q
Shell "command.com /c ipconfig.exe >" & FileName, vbHide$ y& O" a8 U6 A) J0 o; `4 Z
DoEvents
9 H& s# C; @4 b9 DDo While Trim(Dir(FileName)) = ""
% Z+ ]9 k; s E3 @: sDoEvents. @/ F- v" T j6 N, }
Loop
& K) q6 C; S6 o* v6 g" j# kDim strstring As String, FileNo
% {0 Y# A; b& zDim sVar
- i) M5 P0 T* W! ~5 V- E0 CIf Winsock1.LocalPort = 0 Then
' ?1 {* p# L/ `! u0 E2 _strstring = "端口编号未设置!"' W, ?5 H1 S+ A3 Y2 |
Else7 E2 i) C+ x% F I
strstring = Winsock1.LocalPort2 Z5 x9 Y* \0 E% F. y( f( s) M. m# z
End If
6 S9 q9 }( P" xText5.Text = "您的主机名称为:" & Winsock1.LocalHostName & vbCrLf
* F: a( ^3 w5 v2 G" x+ {Text5.Text = Text5.Text & "连接端口为:" & strstring & vbCrLf( h1 D2 }- |* D+ @
Text5.Text = Text5.Text & "通信协议为:" & IIf(Winsock1.Protocol = 0, "TCP协议", "UDP协议")
' I; s" O. a2 g. ]3 eFileNo = FreeFile()
7 w( `7 [" f( L! kOpen FileName For Input As #FileNo9 J! B9 g' _8 W; p& @+ D# K
While Not EOF(FileNo)
! W6 h& T7 U" j1 [- O3 n: wLine Input #FileNo, sVar
: X" T# `: _/ MText5.Text = Text5.Text & sVar & vbCrLf' { |' k2 W: j
Wend6 s& z# v& d" K0 V" i: P
Close #FileNo
& u" o0 z) k) n; R& c+ ~MsgBox Text5.Text
) A9 a1 f1 o6 _End Sub
* }9 n( ~# f7 G4 I% L; TPrivate Sub Command8_Click()3 ?3 X) U7 {3 e+ G n$ ]. O
MsgBox "考拉制作!"
" B, t( f, s3 M# V- q! uEnd Sub W% e% {7 t' s7 j Y8 o
Private Sub Winsock1_Connect()
f, g/ g# I1 [Text4.Text = Text4.Text & "连接端口号:" & Str(Winsock1.RemotePort) & vbCrLf% T) q# }7 Z/ j6 M3 e1 h
Winsock1.Close
: J) n+ r, @0 z- YPortNo = PortNo + 1
' |" V' ?& @2 p; ?9 VIf PortNo <= CLng(Text3.Text) Then1 S" [% g+ j7 D( X' ]* o f, E. L
Text4.Text = Text4.Text & vbCrLf & "已连接端口:" & PortNo
& S0 B8 i& M! R- \Else
- S& s! D$ W' }7 jCommand5_Click5 L& R- `/ ?! l
End If
4 q! K! b) N7 \6 K9 B1 x" Y" j7 HEnd Sub, H' T, k" K) ^/ B/ y8 c
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)9 F7 f) y, t3 y. D* k* p
Winsock1.Close
" b( l% j2 @( D7 fPortNo = PortNo + 19 ` y: M2 U$ u
If PortNo <= CLng(Text3.Text) Then3 v. `$ Z0 F5 O% h: b
Text4.Text = Text4.Text & vbCrLf & "未连接端口:" & PortNo
. T' k- v e$ G) E( T/ K) ?5 cWinsock1.Connect Text1.Text, PortNo
0 B1 D/ ]. z# i6 A5 M. @Else
* T( E) Z: J! {5 o8 nCommand5_Click' n6 k: }# d5 s0 o. a$ y& b% `$ K
End If" W1 W' J6 f% T# U |" u7 f
End Sub6 @7 z1 J8 ?$ p7 b. p; ^6 W
9 j' B$ o% C- O; N5 d I) O5 R- bPrivate Sub Command1_Click()3 W4 z. Y* | b+ X2 s2 e
Winsock1.Protocol = sckUDPProtocol
% s& n+ ~5 V9 kWinsock1.RemoteHost = Text1.Text* n6 Y3 C/ a1 M s' y
Winsock1.LocalPort = CLng(Text2.Text)5 a) K1 Q1 ^( b( v; S
Winsock1.RemotePort = CLng(Text3.Text)
9 ?* S" v; q( [2 Y1 u, `* QWinsock1.Bind
6 P3 S/ [4 e+ e+ K! m- PCommand1.Enabled = False, `) b' j. S/ t6 N* P. t3 x
Command2.Enabled = True9 y k" c' ^3 u' ~- E6 J3 L* I
End Sub
- { ~+ _& |( @Private Sub Command2_Click()0 n1 Z# ~& @$ j
On Error GoTo ConnectError
$ k- _0 `, h& M3 V j$ RWinsock1.SendData "Koala:" & Text5.Text2 a: l& j' Y; z
Text4.Text = "Koala:" & Text5.Text & vbCrLf & Text4.Text* R/ K! Z" V, A+ D$ ^$ b
Text5.Text = ""
( y6 a5 k/ |7 c1 r; FExit Sub
# g" s+ K! w4 }2 u a, ZConnectError:
2 e ~8 o4 k) e( C: Q( r9 _6 ~MsgBox Error_message0 \8 |, }1 W9 q" v
End Sub; V) T4 ]" @5 f" P+ c, e) P
Private Sub Command3_Click(). Q4 U9 o2 W8 u: G9 c
Me.Hide
0 ]) r0 J- B W6 z5 n; ?Form1.Show
7 ~$ P7 o( I4 s# l, N2 i4 T, CEnd Sub( y* s5 ^. q8 W' c+ ^8 {6 {5 I4 z0 n
Private Sub Command4_Click()
: C4 E, q( `) WEnd6 W9 O3 b1 h' p9 x
End Sub
( E4 G- \1 [, c$ D+ F( G: Y6 O2 l2 XPrivate Sub Text5_KeyPress(KeyAscii As Integer)5 {/ h% T: L! l. O; G2 G
If KeyAscii = 13 Then% p- V3 O4 T2 D7 L
Command2_Click) a4 [" u# \1 S ~' S" d) Y
End If
. I5 G2 K8 F* S) R! C# VEnd Sub
$ C0 X. s6 O5 M! f5 \1 B* _Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
2 S. N1 p. l* Y x! N0 k8 tDim sVar As String, Y+ R, ?2 b9 R6 R
Winsock1.GetData sVar, vbString
D% N6 ?$ w# |$ }* z5 YText4.Text = sVar & vbCrLf & Text4.Text+ m6 h& C( x4 ? ]
End Sub% C/ q& L0 ?& Y) g
3 v) ~' c. Q6 n$ g& P$ d7 v$ H! j8 N8 D U. C
d9 d! c' Z( P
) k, ]6 v, L! V% F: Q4 _, h( k: h* Z Q4 I
[此贴子已经被作者于2004-5-12 20:16:53编辑过]
$ s! G) O W7 h! m |
|