[分享]一组基于 WMI 的函数
Dim objs As Object, Obj As Object
Set objs = GetObject("WinMgmts:").InstancesOf("Win32_BaseBoard")
For Each Obj In objs
MainBoardSN = MainBoardSN & IIf(MainBoardSN <> "", ";", "") & Obj.SerialNumber
Next
End Function
'获取网上MAC地址
Public Function NicMAC() As String
Dim Nics As Object, oIP As Object
Set Nics = GetObject("Winmgmts:").InstancesOf("Win32_NetworkAdapterConfiguration")
For Each oIP In Nics
If oIP.IPEnabled = True Then
NicMAC = NicMAC & IIf(NicMAC <> "", ";", "") & oIP.MacAddress
Exit For
End If
Next
End Function
'获取硬盘型号
Public Function HDModel() As String
Dim hds As Object, hd As Object
Set hds = GetObject("Winmgmts:").InstancesOf("Win32_DiskDrive")
For Each hd In hds
HDModel = HDModel & IIf(HDModel <> "", ";", "") & hd.Model
Next
End Function
'获取IP地址
Public Function IP() As String
Dim OpSysSet, OpSys, oIP
Set OpSysSet = GetObject("winmgmts:{impersonationLevel=impersonate}//localhost"). _
ExecQuery("Select index, IPAddress FROM Win32_NetworkAdapterConfiguration")
For Each OpSys In OpSysSet
If TypeName(OpSys.IPAddress) <> "Null" Then
For Each oIP In OpSys.IPAddress
IP = IP & IIf(IP <> "", ";", "") & oIP
Next
End If
Next
End Function
(责任编辑:admin)
- ·关于 Partition 函数在分组查询中的应
- ·Access算术运算符的含义和说明表
- ·mid函数的另类用法
- ·access制作程序运行进度框
- ·Function与Sub的异同(函数调用)
- ·Access判断某个数值是否为某个数据类型
- ·select case后面语句块的值的四种格式
- ·vba条件语句的两种表示方法
- ·Access几种数据类型初始化的值
- ·Access vba null与""空字符串的区别
- ·access vba 数据类型表
- ·Access变量的命名规则
- ·Access中EXIT Sub与End Sub的区别
- ·Access vba中参数前关键字ByRef和ByVal
- ·Access列表框快速全选的技巧【最快】
- ·vba函数的数据类型强制转换