1. Наш канал codeby в telegram. Пишем об информационной безопасности, методах защиты информации, о программировании. Не пропускай новости с кодебай, будь в тренде ! Подробнее ...

    Скрыть объявление

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

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

  1. sergikzhivot

    sergikzhivot Гость

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

    @LE}{@NDER Гость

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

    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:
    Код:
    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.
    Код:
    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.
     
Загрузка...

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