`
chenyuxiaoxiao
  • 浏览: 69592 次
  • 性别: Icon_minigender_1
  • 来自: 西安
社区版块
存档分类
最新评论

vba 获得本机的ip address

VBA 
阅读更多
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
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics