该用户从未签到
|
3楼
楼主 |
发表于 2004-5-12 20:15:00
|
只看该作者
Dim PortNo As Long
, O0 n$ ^, E" sPrivate Sub Command1_Click()
( V9 E; [$ a! J0 o% p0 q4 P- @MsgBox "您的IP地址是:" & Winsock1.LocalIP
4 Q5 r4 d+ y0 a8 I' ` S+ z# M4 pEnd Sub
$ p) a4 o( v) U6 dPrivate Sub Command2_Click()6 `& ?1 Q6 q4 s
MsgBox "您的计算机名称是:" & Winsock1.LocalHostName( B C. o$ ]( @
End Sub
/ E2 S/ c3 Y! o$ {5 ePrivate Sub Command3_Click()0 ^; q# n$ X: u7 D( B7 `8 T9 B6 X( u! y
End. R+ \9 [3 F* |3 o$ T( O
End Sub
6 i' a6 v1 p" r) \( ^Private Sub Command4_Click()/ J3 T( z% H) `+ t( R" C
PortNo = CLng(Text2.Text) - 1
: Y% t1 t ?6 O- |; @& S$ nText4.Text = ""/ M! i8 `6 W+ I7 h
Command5.Enabled = True' ~1 [8 Z' I0 c4 ?3 F/ Y
Command4.Enabled = False0 \7 x# B1 d) H% [/ \" z. i( I
If PortNo < 0 Or PortNo > 32767 Then. b" t! B8 ^$ w) u% |" s$ N
MsgBox "您的输入错误,端口超过范围"
; I7 ]* k, @" y" `- f& Z4 S5 o+ wCommand5_Click5 y% w' M( }* i5 P( t/ g8 c, T
Exit Sub2 X( c( n9 r" I* C
Else
: [/ H+ o/ }; ?Winsock1.Connect Text1.Text, PortNo$ b: s. ^6 ~6 b/ H1 x7 @
Text4.Text = "开始端口扫描......"
/ T# }* m7 d& I3 L- c1 fEnd If
1 ~) J9 I$ c( U+ M/ x ~; w6 ^9 SEnd Sub
& J* C- K9 F) |4 W6 ~8 c9 t. ~Private Sub Command5_Click()
: \9 W2 j4 U8 B% E. ]( x- [Command5.Enabled = False; M' M1 e! x# n5 B$ o: R* U. J
Command4.Enabled = True
; |, o O! n9 q4 Q+ A+ E' Z# wWinsock1.Close0 q" G* V" p" K* B1 V) Y
Text4.Text = Text4.Text & vbCrLf & "端口扫描已停止。"' T: g5 ]4 m, L+ ^
End Sub
y, A3 j8 X$ Y! _' x4 fPrivate Sub Command6_Click()7 H+ ]3 p' G; ~- a" J( ~
Me.Hide( J" D i8 j. C
Form2.Show
{6 v& W9 M7 I$ t& I- ^% i PEnd Sub; D; b: f! q% {0 [
Private Sub Command7_Click()% B& [$ A' R& X- i7 H( Y
FileName = "d:\ipdetail.txt"
# m8 K) c0 R( N0 l% @- K9 |Shell "command.com /c ipconfig.exe >" & FileName, vbHide. ], P, P" t+ X p0 G$ `5 ~ n
DoEvents3 n- _3 u' e6 ?+ Z9 |5 y
Do While Trim(Dir(FileName)) = ""/ |. \4 Q4 ~* @" b7 ]7 m0 G. ?
DoEvents; U: F* D$ V) q: e, i
Loop* Y: t8 z' M" }* k, m, {0 z
Dim strstring As String, FileNo5 Y; k& M5 E n( d l& J% f' ^, [
Dim sVar
1 {7 v! w% J4 cIf Winsock1.LocalPort = 0 Then+ N- K" X9 c& t/ o0 k+ `# m
strstring = "端口编号未设置!"3 Y% O! J& ]% F: n6 c7 U3 i
Else
, G% } Z& U1 K& ? Astrstring = Winsock1.LocalPort! K$ P$ S( l8 Z. I+ v. ^2 Y: Z' Q
End If# i. W f2 h! _9 V1 j5 O
Text5.Text = "您的主机名称为:" & Winsock1.LocalHostName & vbCrLf" G( I; Z* X: Q" P. s
Text5.Text = Text5.Text & "连接端口为:" & strstring & vbCrLf: p3 ~+ S* \$ B1 l% f3 B" j4 o7 b
Text5.Text = Text5.Text & "通信协议为:" & IIf(Winsock1.Protocol = 0, "TCP协议", "UDP协议"), N( b. F$ C7 M) y7 k1 h( u( ?- }
FileNo = FreeFile()
8 k( `1 b0 }6 ^6 d2 POpen FileName For Input As #FileNo
8 ~5 u$ h) A- j- P( E9 g8 rWhile Not EOF(FileNo)3 Q. r/ |, ^2 m2 a" _1 n* g! j
Line Input #FileNo, sVar
* U* G+ _% _& GText5.Text = Text5.Text & sVar & vbCrLf
# p$ O& H) }, z$ |" mWend
7 o5 i$ Z/ c; K- n" |2 m4 @2 gClose #FileNo
; t7 I+ }+ w$ V: R! fMsgBox Text5.Text9 t8 q$ t8 J5 A3 o
End Sub
. K* W. K1 h3 pPrivate Sub Command8_Click()
/ ^' e: d6 p5 N: t' CMsgBox "考拉制作!"8 j/ e7 [" g6 V) y0 B/ ]
End Sub9 _6 q( F" P6 m( h9 Y: y; [; G
Private Sub Winsock1_Connect()5 ^% @$ ?7 _- v
Text4.Text = Text4.Text & "连接端口号:" & Str(Winsock1.RemotePort) & vbCrLf
4 |8 N# s. }- |8 w, D& n% QWinsock1.Close
3 h" \: i& G+ \3 Z/ T) mPortNo = PortNo + 14 ~1 c. Z# w+ y1 e# ^
If PortNo <= CLng(Text3.Text) Then
/ i) Y' ?9 P7 |+ d K& ^1 xText4.Text = Text4.Text & vbCrLf & "已连接端口:" & PortNo
/ J0 m: G1 S9 z( @! O2 K3 H, {$ kElse
7 b4 }" M5 q, j4 |1 t; w$ s7 GCommand5_Click. h+ p# z0 A, Y
End If
: R, p" s! D0 L) Z- U# BEnd Sub
2 e4 ?$ n- @) ^2 c7 j% p5 t. CPrivate 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)
; R0 B* W" H5 bWinsock1.Close
( B3 `4 J! |- D& M5 bPortNo = PortNo + 1
- c0 W3 {, k& _; Y- TIf PortNo <= CLng(Text3.Text) Then+ J0 E" S. f1 }# ]& |4 M
Text4.Text = Text4.Text & vbCrLf & "未连接端口:" & PortNo
' O/ Q0 [1 @+ f, K% ?Winsock1.Connect Text1.Text, PortNo
3 w5 ]/ u# u: n5 b$ NElse' J2 v; [9 [* e; `, w! C4 p
Command5_Click. |/ ]6 L" S4 L) d* K7 w
End If9 {4 e) W) i0 e: S: x) j. L
End Sub& ]( @: R x4 h; m S( t3 f
6 f' K6 K) H8 D) t3 M! h
Private Sub Command1_Click()) L5 t! s4 K1 |; ^
Winsock1.Protocol = sckUDPProtocol; D) X; r [4 e, [3 O
Winsock1.RemoteHost = Text1.Text9 C0 U, O# C' h
Winsock1.LocalPort = CLng(Text2.Text)
) x I. u( K& V& _+ t3 y: \9 E4 tWinsock1.RemotePort = CLng(Text3.Text)6 {- E+ O( p) X% D% v3 J
Winsock1.Bind
3 \$ B5 U) ~, {4 L3 uCommand1.Enabled = False8 g# l$ I p) P4 z) `
Command2.Enabled = True
( m3 U- m" F* [8 k" q; YEnd Sub e! m# }! W; e& E- ^# s# e
Private Sub Command2_Click()$ a) b! W4 z& d/ A
On Error GoTo ConnectError
. y; L6 {; [1 ~1 s9 hWinsock1.SendData "Koala:" & Text5.Text
# s0 x: C: d+ z& b/ w7 BText4.Text = "Koala:" & Text5.Text & vbCrLf & Text4.Text
* x2 I$ F* e" y. oText5.Text = ""
5 m! ?" h# Q9 p, N1 E, @1 sExit Sub$ B6 G" u, o [ N' f& g! u7 C
ConnectError: q) ?1 `; ]$ K5 s9 F6 S# x
MsgBox Error_message
) p' C4 }, A& N( R% mEnd Sub
6 I4 U1 t, r' x {& _Private Sub Command3_Click()
: S& j' H9 V* R3 UMe.Hide
! \- g3 R: A4 `# W5 MForm1.Show# x# u l% g7 n/ ? d: {
End Sub+ a& Z8 |7 v( b. j* [3 G! Z3 ~# [& r
Private Sub Command4_Click()
% z E, h0 l* S9 W/ LEnd
$ y9 {; V+ @: OEnd Sub
( o L0 O) F& ]/ s5 o5 J' S qPrivate Sub Text5_KeyPress(KeyAscii As Integer)
8 s( X8 c( |' c1 K: f; GIf KeyAscii = 13 Then
4 @- V) b0 [: g* }Command2_Click$ B3 Z7 x+ j& k
End If0 C$ h" d% S! `- }
End Sub
! H% W' n' {* _1 o, K0 rPrivate Sub Winsock1_DataArrival(ByVal bytesTotal As Long)* L/ V# K1 ~2 ]" ^) z/ o. O; _
Dim sVar As String9 p- x3 T: r6 v
Winsock1.GetData sVar, vbString% [; k _% g% G; Q
Text4.Text = sVar & vbCrLf & Text4.Text
5 u5 R# k; d. S; k7 H! BEnd Sub
7 Q; B, R1 r* S9 M
, z, c7 y& q9 ^6 w3 u3 g. ^( k1 h, G2 \! |: m1 w! U k
o! J( S% M1 \
5 W- C8 C7 b; h! I6 F( {2 V f' u @3 D8 S
[此贴子已经被作者于2004-5-12 20:16:53编辑过]
* ]- Q* U8 w3 Y6 j |
|