您的位置:首页 > 移动开发 > 微信开发

利用vb写的扫描本机开放端口的小程序.

2007-09-16 18:49 274 查看
利用vb写的扫描本机开放端口的小程序.

4个text 两个按钮.和一个Winsock1控件

Dim portnum As Long
Dim start As String
Sub scanningports()
Dim porttwo As Long
portnum = Text1.Text
porttwo = Text2.Text
Command2.Enabled = True
On Error GoTo viriio
Do
portnum = portnum + 1
DoEvents
If start = True Then
Winsock1.Close
DoEvents
Winsock1.LocalPort = portnum
DoEvents
Text3.Text = portnum
Winsock1.Listen
DoEvents
Else
portnum = 0
Command1.Enabled = True
Text1.Locked = False
Text2.Locked = False
Exit Sub
End If
Winsock1.Close
DoEvents
Loop Until portnum >= porttwo
portnum = 0
Command1.Enabled = True
logport.Text = logport.Text & vbCrLf & "Scanning Ports Done!" & vbCrLf
Text1.Locked = False
Text2.Locked = False
viriio:
If Err.Number = 10048 Then
logport.Text = logport.Text & vbCrLf & "端口" & Winsock1.LocalPort & " 开启中"
Resume Next
End If

End Sub

Private Sub Command1_Click()
Command2.Enabled = True
If Text1.Text = "" Then
MsgBox "你必须指定开始端口号!"
Exit Sub
End If
If Text2.Text = "" Then
MsgBox "你必须指定一个结束端口号"
Exit Sub
End If

Text1.Locked = True
Text2.Locked = True
Command1.Enabled = False
Winsock1.Close
start = True
Call scanningports
logport.Text = logport.Text & vbCrLf & "端口" & Text1.Text & "- " & Text3.Text & " 已经成功扫描!"

End Sub

Private Sub Command2_Click()
Command2.Enabled = False
start = False
End Sub
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: