扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:maqiaos_cn 来源:vb新世纪 2007年10月14日
关键字: Visual Basic 编程访问 WMI
Function Enum1() As String Dim WMI Set WMI = GetObject("WinMgmts:") Set objs = WMI.InstancesOf("Win32_Process") For Each obj In objs Enum1 = Enum1 + obj.Description + Chr(13) + Chr(10) Next End Function |
Private Sub Command1_Click() Dim s, System, item Dim i As Integer Set System = GetObject("winmgmts:").InstancesOf("Win32_ComputerSystem") For Each item In System ‘List1.AddItem item.cputype s = "Computer Info" & vbCrLf s = s & "***********************" & vbCrLf s = s & "计算机名称: " & item.name & vbCrLf s = s & "状态: " & item.Status & vbCrLf s = s & "类型: " & item.SystemType & vbCrLf s = s & "生产厂家: " & item.Manufacturer & vbCrLf s = s & "型号: " & item.Model & vbCrLf s = s & "内存: ~" & item.totalPhysicalMemory \ 1024000 & "mb" & vbCrLf s = s & "域: " & item.domain & vbCrLf ‘s = s & "工作组" & item.Workgroup & vbCrLf ‘获得工作组和域的选项不能同时用 s = s & "当前用户: " & item.username & vbCrLf s = s & "启动状态" & item.BootupState & vbCrLf s = s & "该计算机属于" & item.PrimaryOwnerName & vbCrLf s = s & "系统类型" & item.CreationClassName & vbCrLf s = s & "计算机类类型" & item.Description & vbCrLf For i = 0 To 1 ‘这里假设安装了两个系统 s = s & Chr(5) & "启动选项" & i & " :" & item.SystemStartupOptions(i) _ & vbCrLf Next i Next Text1.Text = s End Sub |
Private Function MACAddress() As String Set objs = GetObject("winmgmts:").ExecQuery( _ "SELECT MACAddress " & _ "FROM Win32_NetworkAdapter " & _ "WHERE " & _ "((MACAddress Is Not NULL) " & _ "AND (Manufacturer <> " & _ "‘Microsoft‘))") For Each obj In objs MACAddress = obj.MACAddress Exit For Next obj End Function |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者