Function GetIP() As String
    Dim OpSysSet As Object, Op As Object, Ip
    Set OpSysSet = GetObject("winmgmts:{impersonationLevel=impersonate}//localhost").ExecQuery("SELECT index, IPAddress FROM Win32_NetworkAdapterConfiguration")
    For Each Op In OpSysSet
        If Not IsNull(Op.IPAddress) Then
            For Each Ip In Op.IPAddress
                If Ip Like "*.*.*.*" Then
                    GetIP = Ip
                    Exit Function
                End If
            Next
        End If
    Next
End Function

 

posted on 2023-10-07 16:15  sonycat  阅读(477)  评论(1编辑  收藏  举报