|
從外地取得的 System Info 例子
Sub SysInfo()
Dim s As String, oSystem As Object, item As Object
Set oSystem = GetObject("winmgmts:").instancesOf("Win32_ComputerSystem")
For Each item In oSystem
s = "Computer Info" & vbCrLf
s = s & "-------------------------------" & vbCrLf
s = s & "Name: " & item.Name & vbCrLf
s = s & "Status: " & item.Status & vbCrLf
s = s & "Type: " & item.SystemType & vbCrLf
s = s & "Mfg: " & item.Manufacturer & vbCrLf
s = s & "Model: " & item.Model & vbCrLf
s = s & "RAM: " & item.TotalPhysicalMemory \ 1024000 & "mb" & vbCrLf
s = s & "Domain: " & item.Domain & vbCrLf
s = s & "Role: " & TranslateDomainRole(item.DomainRole) & vbCrLf
s = s & "Current User: " & item.UserName & vbCrLf
MsgBox s
Next
Set oSystem = Nothing
End Sub
Function TranslateDomainRole(ByVal roleID) As String
Dim RetString As String
Select Case roleID
Case 0
RetString = "Standalone Workstation"
Case 1
RetString = "Member Workstation"
Case 2
RetString = "Standalone Server"
Case 3
RetString = "Member Server"
Case 4
RetString = "Backup Domain Controller"
Case 5
RetString = "Primary Domain Controller"
Case Else
RetString = "Unknown"
End Select
TranslateDomainRole = RetString
End Function |
|