在远程电脑上获取本地IP地址的方法(VB编程)

2025-02-25 19:43:26
推荐回答(1个)
回答1:

Sub GetObject获取IP地址()
   ComputerName = "localhost"
   Set OpSysSet = GetObject("winmgmts:{impersonationLevel=impersonate}//" & ComputerName).ExecQuery("SELECT index, IPAddress FROM Win32_NetworkAdapterConfiguration")
   For Each OpSys In OpSysSet
      If TypeName(OpSys.IPAddress) <> "Null" Then
         For Each ip In OpSys.IPAddress
            MsgBox ip, 64, "IP地址"
         Next
      End If
   Next
End Sub