Jump to content
antrax

CPU e Memória do PC

Recommended Posts

antrax

Boa Tarde pessoal

Mando aqui uma aplicação com o codigo que permite ver o processador e a memoria. Foi uma brincadeira que eu fiz  com uma linha de codigo que achei na net e

depois juntei mais algumas coisa e deu isto...convém ligar o som.

Ingredientes:

2 performance counter

2 timer

2 Progressbar

Properties:
performance Counter1
Nome....performance counter1
Category name... Processador
counter name ....%de tempo do processador
instance name..._total
performance Counter2
nome...performance counter 2
category name....memoria
counter name....% dos bytes consolidades em utilização
timer1
name...timer1
interval ....150
timer2
name...timer2
interval ...25

codigo na form:

Public Class Form1
    Dim cpu1 As Integer
    Dim SAPI
    Dim ram As Integer


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim CPUName As String
        CPUName = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\SYSTEM\CentralProcessor\0", "ProcessorNameString", Nothing)
        Timer1.Enabled = True
        Timer2.Enabled = True
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        cpu1 = PerformanceCounter1.NextValue
        ram = PerformanceCounter2.NextValue
    End Sub

    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
        If ProgressBar1.Value < cpu1 Then
            ProgressBar1.Value += 1
        ElseIf ProgressBar1.Value > cpu1 Then
            ProgressBar1.Value -= 1
        End If
        If ProgressBar2.Value < ram Then
            ProgressBar2.Value += 1
        ElseIf ProgressBar2.Value > ram Then
            ProgressBar2.Value -= 1
        End If
        SAPI = CreateObject("sapi.spvoice")
        SAPI.Speak(Label3.Text)
        Label3.Text = ProgressBar1.Value.ToString + "%"
        Label4.Text = ProgressBar2.Value.ToString + "%"

        
    End Sub

    

    Private Sub ProgressBar1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProgressBar1.Click

    End Sub

    Private Sub ProgressBar2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProgressBar2.Click

    End Sub
End Class

Leva algum tempo para arrancar mas é engraçado

Share this post


Link to post
Share on other sites
thoga31

Mete o código entre as tags [ code=vbnet ][ /code ], sem espaços. Fica o código distinto do resto do texto.

É certo que neste momento o GeSHi foi abaixo, mas vai ser implementado em breve de novo, e nessa altura voltaremos a ter cor.


Knowledge is free!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.