📄 frmmain.frm
字号:
VERSION 5.00
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
Begin VB.Form frmMain
Caption = "局域网扫描"
ClientHeight = 2085
ClientLeft = 60
ClientTop = 345
ClientWidth = 5955
LinkTopic = "Form1"
ScaleHeight = 2085
ScaleWidth = 5955
StartUpPosition = 3 '窗口缺省
Begin VB.ListBox lstRes
Appearance = 0 'Flat
Height = 1770
IntegralHeight = 0 'False
Left = 2940
TabIndex = 6
Top = 180
Width = 2895
End
Begin MSWinsockLib.Winsock wskSock
Left = 120
Top = 120
_ExtentX = 741
_ExtentY = 741
_Version = 393216
End
Begin VB.TextBox txtTo
Appearance = 0 'Flat
Height = 285
Left = 2108
TabIndex = 4
Top = 540
Width = 495
End
Begin VB.TextBox txtFrom
Appearance = 0 'Flat
Height = 285
Left = 2108
TabIndex = 3
Top = 180
Width = 495
End
Begin VB.CommandButton cmdFind
Caption = "扫描"
Height = 375
Left = 938
TabIndex = 0
Top = 960
Width = 1215
End
Begin VB.Label lblAction
Alignment = 2 'Center
Height = 195
Left = 360
TabIndex = 7
Top = 1440
Width = 2415
End
Begin VB.Label lblNow
Alignment = 2 'Center
Caption = "Ready."
Height = 195
Left = 315
TabIndex = 5
Top = 1740
Width = 2475
End
Begin VB.Label lblFrom
Alignment = 1 'Right Justify
Caption = "起始 000.000.000."
Height = 195
Left = 488
TabIndex = 2
Top = 240
Width = 1575
End
Begin VB.Label lblTo
Alignment = 1 'Right Justify
Caption = "结束 000.000.000."
Height = 195
Left = 488
TabIndex = 1
Top = 600
Width = 1575
End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'' Gonzalo Arreche - 2005
''''''
Option Explicit
Private mmp As clsNet
Private myIp As String
Private netIp As String
Private Function Get_Net_Ip(mIp As String)
' Get 3 first numbers of IP and
' returns a string like "192.168.62."
Dim i As Integer
' By old way
Let i = InStr(1, mIp, ".")
Let i = InStr(i + 1, mIp, ".")
Let i = InStr(i + 1, mIp, ".")
Let Get_Net_Ip = Mid(mIp, 1, i)
End Function
Private Sub Add_Mach(mName As String, mIp As String)
' Add machine to list
Call lstRes.AddItem(mName & " (" & mIp & ")")
End Sub
Private Sub cmdFind_Click()
' Scan engine :D
Dim i As Integer
Dim s As String
Dim f As Integer, t As Integer
If (IsNumeric(txtFrom.Text)) Then Let f = txtFrom.Text
If (IsNumeric(txtTo.Text)) Then Let t = txtTo.Text
' Error handler ;)
If ((f < 0) Or (t < 0)) Then Exit Sub
If (t < f) Then Exit Sub
' ---------
For i = f To t
Let lblAction.Caption = "正在扫描中..."
Let s = netIp & i
Let lblNow.Caption = s
DoEvents ' don't say.. :(
If (s <> myIp) Then ' don't add, it's me !
If (mmp.Ping(s)) Then '
Let lblAction.Caption = "分解主机名..."
DoEvents ' Again..
Call Add_Mach(mmp.ResolveHostname(s), s)
End If
End If
Next i
Let lblAction.Caption = ""
Let lblNow.Caption = "完毕."
End Sub
Private Sub Form_Load()
' Setup variables
Set mmp = New clsNet
Let myIp = wskSock.LocalIP
Let netIp = Get_Net_Ip(myIp)
Let lblFrom.Caption = "起始 " & netIp
Let lblTo.Caption = "结束 " & netIp
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -