CPU analysis

Post Reply
User avatar
Antonio Linares
Site Admin
Posts: 42404
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 12 times
Been thanked: 48 times
Contact:

CPU analysis

Post by Antonio Linares »

Thanks to Charly:

Code: Select all | Expand

LOCAL  oLoc :=  CreateObject( "wbemScripting.SwbemLocator" )
    LOCAL  objWMI := oLoc:ConnectServer()
    LOCAL   hAppInfo := {=>}
    LOCAL   oError, oDatos, oJbs 

    TRY
        oJbs := objWMI:ExecQuery("SELECT * FROM Win32_Processor")
        
        FOR EACH oDatos IN oJbs
            hAppInfo['cpu_usage'] := Alltrim(hb_CStr(oDatos:LoadPercentage))
            hAppInfo['cpu_name'] := Alltrim(hb_CStr(oDatos:Name))
            hAppInfo['cpu_cores'] := Alltrim(hb_CStr(oDatos:NumberOfCores))
            hAppInfo['cpu_threads'] := Alltrim(hb_CStr(oDatos:NumberOfLogicalProcessors))
        NEXT
    CATCH oError
        hAppInfo['cpu_usage'] := '0'
        hAppInfo['cpu_name'] := ''
        hAppInfo['cpu_cores'] := '0'
        hAppInfo['cpu_threads'] := '0'
    END
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply