当前位置: 代码迷 >> VBA >> vba 取得本机的ip address
  详细解决方案

vba 取得本机的ip address

热度:1452   发布时间:2013-02-26 00:00:00.0
vba 获得本机的ip address
Dim strComputer As String    Dim objWMI As Object    Dim colIP As Object    Dim IP As Object    Dim i As Integer    Dim ipserver As String    ipserver = ""        strComputer = "."    Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")    Set colIP = objWMI.ExecQuery _        ("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")            For Each IP In colIP        If Not IsNull(IP.IPAddress) Then            For i = LBound(IP.IPAddress) To UBound(IP.IPAddress)                ipserver = IP.IPAddress(i)                MsgBox IP.IPAddress(i), vbInformation, IP.Description(i)                MsgBox (ipserver)        Next        End If    Next
  相关解决方案