процент загрузки процессора для Mfc(c++)

Тема в разделе "MS Visual C++", создана пользователем sergikzhivot, 2 авг 2009.

  1. sergikzhivot

    sergikzhivot Гость

    как программно снять процент загрузки процессора для MFC(C++)
     
  2. @LE}{@NDER

    @LE}{@NDER Гость

    Думаю тебе нужны следующие структура и функция (для полной инфы ищи в МСДНе):

    1) SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION

    When the SystemInformationClass parameter is SystemProcessorPerformanceInformation, the buffer pointed to by the SystemInformation parameter should be large enough to hold an array that contains as many SYSTEM_PROCESS_INFORMATION structures as there are processors (CPUs) installed in the system. Each structure has the following layout:
    Код (Text):
    typedef struct
    _SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION {
    LARGE_INTEGER IdleTime;
    LARGE_INTEGER KernelTime;
    LARGE_INTEGER UserTime;
    LARGE_INTEGER Reserved1[2];
    ULONG Reserved2;
    } SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION;
    The IdleTime member contains the amount of time that the system has been idle, in 100-nanosecond intervals.

    The KernelTime member contains the amount of time that the system has spent executing in Kernel mode (including all threads in all processes, on all processors), in 100-nanosecond intervals.

    The UserTime member contains the amount of time that the system has spent executing in User mode (including all threads in all processes, on all processors), in 100-nanosecond intervals.

    GetSystemTimes()

    2) GetSystemTimes() Function

    Retrieves system timing information. On a multiprocessor system, the values returned are the sum of the designated times across all processors.
    Код (Text):
    BOOL WINAPI GetSystemTimes(
    __out        LPFILETIME lpIdleTime,
    __out        LPFILETIME lpKernelTime,
    __out        LPFILETIME lpUserTime
    );
    Parameters
    lpIdleTime
    A pointer to a FILETIME structure that receives the amount of time that the system has been idle.

    lpKernelTime
    A pointer to a FILETIME structure that receives the amount of time that the system has spent executing in Kernel mode (including all threads in all processes, on all processors).

    lpUserTime
    A pointer to a FILETIME structure that receives the amount of time that the system has spent executing in User mode (including all threads in all processes, on all processors).

    Return Value
    If the function succeeds, the return value is nonzero.

    If the function fails, the return value is zero. To get extended error information, call GetLastError.
     
Загрузка...

Поделиться этой страницей