답변:
컴퓨터의 IP와 이름을 모두 얻는 아래 기능을 찾으십시오. IP의 범위를 변경하십시오.
각 IP를 핑하고 응답을 찾습니다.
Public Function mCheckThroughWMIQuery() As String
Dim oWMI = GetObject("winmgmts:")
Dim IP = GetObject("winmgmts:")
Dim oPings = GetObject("winmgmts:")
Dim PcName = GetObject("winmgmts:")
Dim sResult As String = ""
For i = 70 To 100
IP = "192.168.1." + i.ToString
oPings = oWMI.ExecQuery("Select * from WIN32_Pingstatus where address='" + IP + "'" + " and ResponseTime > 0")
For Each oPing In oPings
Try
PcName = System.Net.Dns.GetHostEntry(IP)
sResult &= IP & Chr(9) & PcName.HostName & vbNewLine
Catch ex As Exception
sResult &= IP & vbNewLine
End Try
Next
Next
Return sResult
End Function