分享

VBA 获取IP地址方法

 恐怖骑士 2012-05-10
Public Sub GetMyIP()
    Dim strComputer As String
    Dim objWMI As Object
    Dim colIP As Object
    Dim IP As Object
    Dim i As Integer

    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)
                MsgBox IP.IPAddress(i), vbInformation, IP.Description(i)
        Next
        End If
    Next
MsgBox "Excel版本信息为:" & Application.CalculationVersion
  MsgBox "Excel当前允许使用的内存为:" & Application.MemoryFree
  MsgBox "Excel当前已使用的内存为:" & Application.MemoryUsed
  MsgBox "Excel可以使用的内存为:" & Application.MemoryTotal
  MsgBox "本机操作系统的名称和版本为:" & Application.OperatingSystem
  MsgBox "本产品所登记的组织名为:" & Application.OrganizationName
  MsgBox "当前用户名为:" & Application.UserName
  MsgBox "当前使用的Excel版本为:" & Application.Version
End Sub

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多