strComputer = "."
strMesseage=""
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
‘获取本机计算机名
Set colSettings = objWMIService.ExecQuery ("Select * from Win32_ComputerSystem")
For Each objComputer in colSettings
strMesseage = "System Name: " & objComputer.Name & vbCr&vbCr
Next
‘获取本机IP地址
Set IPConfigSet = objWMIService.ExecQuery ("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE")
For Each objItem In IPConfigSet
For Each objAddress In objItem.IPAddress
If objAddress <> "" And objAddress <> "0.0.0.0" Then
strMesseage = strMesseage & "IP Address: " & objAddress & vbCr&vbCr
End If
Next
Next
i=MsgBox(strMesseage, vbOKOnly&vbInformation, "System Infomation")
时间: 2024-10-28 22:09:07