1#include"windows.h"2#include"tlhelp32.h"3#include"iostream"4 using namespacestd;5 6 #pragmaComment (lib, "Kernel32.lib")7 8DWORD Getkernelmodepercentage (Constfiletime&Ftkernel,9 Constfiletime&FtuserTen ){ OneUlonglong qwkernel= ((ulonglong) ftkernel.dwhighdatetime) << +)+Ftkernel.dwlowdatetime; AUlonglong qwuser= ((ulonglong) ftuser.dwhighdatetime) << +)+Ftuser.dwlowdatetime; -ULONGLONG qwtotal=qwkernel+Qwuser; -DWORD Dwpct= (DWORD) ((ULONGLONG) -*qwkernel)/qwtotal); the return(dwpct); - - - } + - voidMain () { +HANDLE hsnapshot=CreateToolhelp32Snapshot ( A th32cs_snapprocess, at 0 - ); - - PROCESSENTRY32 PE; - -ZeroMemory (&pe,sizeof(PE)); inPe.dwsize=sizeof(PE); - toBOOL Bmore=process32first (hsnapshot,&PE); + - while(bmore) { theHANDLE hprocess=OpenProcess ( * Process_query_information, $ FALSE,Panax Notoginseng Pe.th32processid - ); the + if(hprocess!=NULL) { A FILETIME ftcreation,ftkernelmode,ftusermode,ftexit; the Getprocesstimes ( + hprocess, -&Ftcreation, $&Ftexit, $&Ftkernelmode, -&ftusermode); - theDWORD dwpctkernel=Getkernelmodepercentage ( - Ftkernelmode,Wuyi Ftusermode the ); - Wucout<<"process ID:"<<Pe.th32processid -<<", EXE file:"<<Pe.szexefile About<<",% in Kernel mode:"<<dwPctKernel<<Endl; $ - CloseHandle (hprocess); - } -Bmore=process32next (hsnapshot,&PE); A } + the - GetChar (); $}