CPU analysis

CPU analysis

Postby Antonio Linares » Sat Nov 16, 2024 8:28 am

Thanks to Charly:
Code: Select all  Expand view
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
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Return to Utilities / Utilidades

Who is online

Users browsing this forum: No registered users and 3 guests