Imports System.Management
Imports System.Management.ManagementQuery
Public Class Form1
Private objMgmt As ManagementObject
Private objOS As ManagementObjectSearcher
Dim PercentualeCpu As New PerformanceCounter("Processor", "% Processor Time", "_Total")
Dim PercentualeCpuIntera As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Start()
objOS = New ManagementObjectSearcher("SELECT * FROM Win32_Processor")
Try
For Each objMgmt In objOS.Get
Me.Label13.Text = objMgmt("Name").ToString()
Me.Label14.Text = objMgmt("Family").ToString()
Me.Label15.Text = objMgmt("Manufacturer").ToString()
Me.Label16.Text = objMgmt("CurrentClockSpeed").ToString() & " MHz"
Me.Label17.Text = objMgmt("DeviceID").ToString()
Me.Label18.Text = objMgmt("ExtClock").ToString() & " MHz"
Me.Label19.Text = objMgmt("L2CacheSize").ToString() & " KB"
Me.Label20.Text = objMgmt("L2CacheSpeed").ToString() & " MHz"
Me.Label21.Text = objMgmt("Description").ToString()
Me.Label22.Text = objMgmt("SocketDesignation").ToString()
Me.Label23.Text = objMgmt("Status").ToString()
Select Case objMgmt("ProcessorType").ToString()
Case "1"
Me.Label24.Text = "Altro"
Case "2"
Me.Label24.Text = "Sconosciuto"
Case "3"
Me.Label24.Text = "Processore Centrale"
Case "4"
Me.Label24.Text = "Processore Aritmetico"
Case "5"
Me.Label24.Text = "Processore DSP"
Case "6"
Me.Label24.Text = "Processore Video"
End Select
Select Case objMgmt("Availability").ToString()
Case "1"
Me.Label25.Text = "Altro"
Case "2"
Me.Label25.Text = "Sconosciuto"
Case "3"
Me.Label25.Text = "In uso / Carico massimo"
Case "4"
Me.Label25.Text = "Attenzione"
Case "5"
Me.Label25.Text = "Fase di test"
Case "6"
Me.Label25.Text = "Non applicabile"
Case "7"
Me.Label25.Text = "Alimentazione spenta"
Case "8"
Me.Label25.Text = "Non in linea"
Case "9"
Me.Label25.Text = ""
Case "10"
Me.Label25.Text = "Degradato"
Case "11"
Me.Label25.Text = "Non installato"
Case "12"
Me.Label25.Text = "Errore di installazione"
End Select
Me.Label27.Text = objMgmt("DataWidth").ToString() & " Bit"
Next
Catch ex As Exception
MessageBox.Show(ex.ToString, "Errore eccezione non gestita", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
PercentualeCpuIntera = (PercentualeCpu.NextValue().ToString())
Me.ProgressBar1.Value = PercentualeCpuIntera
Me.lblPercentualeCPU.Text = " " & PercentualeCpuIntera.ToString & "%"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
AboutBox1.Show()
End Sub
End Class