Option Strict Off
Option Explicit On
Friend Class WMISysInfo
Inherits System.Windows.Forms.Form
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByRef lParam As Int32()) As Integer
Public totalupdates As Integer
Private Sub Command1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command1.Click
End
End Sub
Private Sub wmiProcessorInfo()
Dim cpuSet As WbemScripting.SWbemObjectSet
Dim cpu As WbemScripting.SWbemObject
Dim cpus(10) As String
cpuSet = GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("Win32_Processor")
For Each cpu In cpuSet
cpus(0) = cpu.CurrentClockSpeed
cpus(1) = cpu.L2CacheSize
cpus(2) = cpu.LoadPercentage
Next cpu
Dim setSys As WbemScripting.SWbemObjectSet
Dim sys As WbemScripting.SWbemObject
Dim syss(10) As String
setSys = GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("Win32_OperatingSystem")
For Each sys In setSys
syss(0) = sys.TotalVisibleMemorySize
syss(1) = sys.FreePhysicalMemory
syss(2) = sys.TotalVirtualMemorySize
syss(3) = sys.FreeVirtualMemory
syss(4) = sys.OSType
If CDbl(syss(4)) = 16 Then
syss(7) = " Windows 95"
ElseIf CDbl(syss(4)) = 17 Then
syss(7) = " Windows 98"
ElseIf CDbl(syss(4)) = 18 Then
syss(7) = " WINNT"
End If
syss(5) = sys.Status '(SMART disk status)
syss(6) = sys.NumberOfProcesses
Next sys
Dim netSys As WbemScripting.SWbemObjectSet
Dim net As WbemScripting.SWbemObject
Dim nets(10) As String
netSys = GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("Win32_NetworkAdapter")
For Each net In netSys
Next net
FileOpen(1, Text2.Text, OpenMode.Output)
PrintLine(1, "----------------------------------------------------------------------")
PrintLine(1, "Server Info: (updated every " & (CDbl(Text1.Text) / 1000) & " seconds)")
PrintLine(1, "----------------------------------------------------------------------")
PrintLine(1, "CPU Type: " & cpus(3))
PrintLine(1, "Current Clock Speed: " & cpus(0) & "MHz")
PrintLine(1, "L2 Cache Size: " & cpus(1) & "KB")
PrintLine(1, "----------------------------------------------------------------------")
PrintLine(1, "CPU Load: " & cpus(2) & "%")
PrintLine(1, "----------------------------------------------------------------------")
PrintLine(1, "Total RAM: " & CShort(CDbl(syss(0)) / 1024) & " MB")
PrintLine(1, "Free RAM: " & CShort(CDbl(syss(1)) / 1024) & " MB")
PrintLine(1, "Total VMem: " & CShort(CDbl(syss(2)) / 1024) & " MB")
PrintLine(1, "Available VMem: " & CShort(CDbl(syss(3)) / 1024) & " MB")
PrintLine(1, "----------------------------------------------------------------------")
PrintLine(1, "S.M.A.R.T. Status: " & syss(5))
PrintLine(1, "Processes Running: " & syss(6))
PrintLine(1, "----------------------------------------------------------------------")
FileClose(1)
Label3.Text = "Server Info: (updated every " & (CDbl(Text1.Text) / 1000) & " seconds)"
Label4.Text = "----------------------------------------------------------------------"
Label5.Text = "CPU Type: " & cpus(3)
Label6.Text = "Current Clock Speed: " & cpus(0) & "MHz"
Label7.Text = "L2 Cache Size: " & cpus(1) & "KB"
Label8.Text = "----------------------------------------------------------------------"
Label9.Text = "CPU Load: " & cpus(2) & "%"
Label10.Text = "----------------------------------------------------------------------"
Label11.Text = "Total RAM: " & CShort(CDbl(syss(0)) / 1024) & " MB"
Label12.Text = "Free RAM: " & CShort(CDbl(syss(1)) / 1024) & " MB"
Label13.Text = "Total VMem: " & CShort(CDbl(syss(2)) / 1024) & " MB"
Label14.Text = "Available VMem: " & CShort(CDbl(syss(3)) / 1024) & " MB"
Label15.Text = "----------------------------------------------------------------------"
Label16.Text = "S.M.A.R.T. Status: " & syss(5)
Label17.Text = "Processes Running: " & syss(6)
Label18.Text = "----------------------------------------------------------------------"
End Sub
Private Sub Command2_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command2.Click
If Timer1.Enabled = False Then
Timer1.Enabled = True
Timer1.Interval = CInt(Text1.Text)
Command2.Text = "Pause WMISysInfo"
Text1.Enabled = False
Text2.Enabled = False
ElseIf Timer1.Enabled = True Then
Timer1.Enabled = False
Command2.Text = "Start WMISysInfo"
Text1.Enabled = True
Text2.Enabled = True
End If
End Sub
Private Sub WMISysInfo_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
totalupdates = 0
End Sub
Private Sub Timer1_Tick(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Timer1.Tick
Call wmiProcessorInfo()
totalupdates = totalupdates + 1
End Sub
End Class