如何用VB写个查看本地IP、计算机名和MAC

来源:百度知道 编辑:UC知道 时间:2024/06/08 06:42:46
直接生成EXE工程,点击就可以看到。如图:

'来个简单点的
'复制下面代码,运行即可。

'=====代码部分=====
Option Explicit

Private Sub Form_Activate()
Dim WshNetwork, objWMIService, IPConfigSet, IPConfig, colNetworkAdapters, objNetworkAdapter
Dim b, c, i, j, k, t, strComputer

With Me
.Caption = "查询IP机号"
.AutoRedraw = True
.Font.Size = 12
.Font.Bold = True
.Width = 4260
.Height = 3135
End With

Const ForReading = 1, ForWriting = 2
On Error Resume Next

Set WshNetwork = CreateObject("WScript.Network")
b = WshNetwork.ComputerName

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set IPConfigSet = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each IPConfig In IPConfigSet
If Not IsNull(IPConfig.IPAddress) Then