打印本文 打印本文 关闭窗口 关闭窗口
--------监视你的 TCP/IP端口!!!(vb)-----------
作者:武汉SEO闵涛  文章来源:敏韬网  点击数997  更新时间:2009/4/23 18:58:06  文章录入:mintao  责任编辑:mintao

      Option Explicit

      Const PortsChecked = 200

      Private Sub Command1_Click()
         Timer1.Enabled = True
         Timer1.Interval = 1000
      End Sub

      Private Sub Command2_Click()
         Timer1.Interval = 0
         Timer1.Enabled = False
      End Sub

      Private Sub Timer1_Timer()
         Dim X As Integer

         List1.Clear
         For X = 1 To PortsChecked
            DoEvents
            Text1.Text = X
            WinSock1.LocalPort = X
            On Error Resume Next
            WinSock1.Listen  '''' If we get an error, the port is busy.
            If Err.Number = 10048 Then
               List1.AddItem X  '''' Log Active port # to list box.
               Err.Number = 0
            End If

            WinSock1.Close
         Next X
      End Sub

      Private Sub Form_Load()
         Label1.Caption = "Checking Port #"
         Label2.Caption = "Ports In Use"
         Command1.Caption = "Start"
         Command2.Caption = "End"
         Text1.Locked = True
      End Sub 

打印本文 打印本文 关闭窗口 关闭窗口