llTempTime /= 10000;
printf("=:",llTempTime/(60*60*1000));
llTempTime %= 60*60*1000;
printf("%.2d:",llTempTime/(60*1000));
llTempTime %= 60*1000;
printf("%.2d.",llTempTime/1000);
llTempTime %= 1000;
printf("%.3d",llTempTime);
printf("n");
dwTotalProcess;
pSystemProc = (PSYSTEM_PROCESSES)((char *)pSystemProcpSystemProc->NextEntryDelta);
}
printf("--------------------------------------------------------------------------n");
printf("nTotal %d Process(es) !nn",dwTotalProcess);
printf("PIDt ==> Process Identificationn");
printf("PPIDt ==> Parent Process Identificationn");
printf("WsSizet ==> Working Set Sizen");
printf("Prio.t ==> Base Priorityn");
printf("Threadt ==> Thread Countn");
printf("Handlet ==> Handle Countn");
printf("CPU Time ==> Processor Timen");
}
__finally
{
if(lpSystemInfo != NULL)
{
free(lpSystemInfo);
}
if(hNtDll != NULL)
{
FreeLibrary(hNtDll);
}
}
return 0;
}
DWORD SpeciProcess(DWORD dwPID)
{
PSYSTEM_PROCESSES; pSystemProc= NULL;
PSYSTEM_THREADSpSystemThre= NULL;;
HMODULEhNtDll = NULL;
LPVOID lpSystemInfo= NULL;
DWORD; dwNumberBytes; = MAX_INFO_BUF_LEN;
DWORD; dwTotalProcess = 0;
DWORD; dwReturnLength;
NTSTATUSStatus;
LONGLONGllTempTime;
ULONG; ulIndex;
__try
{
hNtDll = LoadLibrary("NtDll.dll");
if(hNtDll == NULL)
{
printf("LoadLibrary Error: %dn",GetLastError());
__leave;
}
NtQuerySystemInformation = (NTQUERYSYSTEMINFORMATION)GetProcAddress(hNtDll,"NtQuerySystemInformation");
if(NtQuerySystemInformation == NULL)
{
printf("GetProcAddress for NtQuerySystemInformation Error: %dn",GetLastError());
__leave;
}
lpSystemInfo = (LPVOID)malloc(dwNumberBytes);
Status = NtQuerySystemInformation(NT_PROCESSTHREAD_INFO,
lpSystemInfo,
dwNumberBytes,
&dwReturnLength);
if(Status == STATUS_INFO_LENGTH_MISMATCH)
{
printf("STATUS_INFO_LENGTH_MISMATCHn");
__leave;
}
else if(Status != STATUS_SUCCESS)
{
printf("NtQuerySystemInformation Error: %dn",GetLastError());
__leave;
}
pSystemProc = (PSYSTEM_PROCESSES)lpSystemInfo;
while(pSystemProc->NextEntryDelta != 0)
{
if(pSystemProc->ProcessId == dwPID)
{
printf("ProcessName:tt ");
if(pSystemProc->ProcessId != 0)
{
wprintf(L"%-20sn",pSystemProc->ProcessName.Buffer);
}
else
{
wprintf(L"%-20sn",L"System Idle Process");
}
printf("ProcessID:tt %dtt",pSystemProc->ProcessId);
printf("ParentProcessID:t%dn",pSystemProc->InheritedFromProcessId);
printf("KernelTime:tt ");
llTempTime; = pSystemProc->KernelTime.QuadPart;
llTempTime /= 10000;
printf("%d:",llTempTime/(60*60*1000));
llTempTime %= 60*60*1000;
printf("%.2d:",llTempTime/(60*1000));
llTempTime %= 60*1000;
printf("%.2d.",llTempTime/1000);
llTempTime %= 1000;
printf("%.3dt",llTempTime);
printf("UserTime:tt");
llTempTime; = pSystemProc->UserTime.QuadPart;
llTempTime /= 10000;
printf("%d:",llTempTime/(60*60*1000));
llTempTime %= 60*60*1000;
printf("%.2d:",llTempTime/(60*1000));
llTempTime %= 60*1000;
printf("%.2d.",llTempTime/1000);
llTempTime %= 1000;
printf("%.3dn",llTempTime);
printf("Privilege:tt %d%%tt",(pSystemProc->KernelTime.QuadPart * 100)/(pSystemProc->KernelTime.QuadPartpSystemProc->UserTime.QuadPart));
printf("User:ttt%d%%n",(pSystemProc->UserTime.QuadPart * 100)/(pSystemProc->KernelTime.QuadPartpSystemProc->UserTime.QuadPart));
printf("ThreadCount:tt %dtt",pSystemProc->ThreadCount);
printf("HandleCount:tt%dn",pSystemProc->HandleCount);
printf("BasePriority:tt %-2dtt",pSystemProc->BasePriority);
printf("PageFaultCount:tt%dnn",pSystemProc->VmCounters.PageFaultCount);
printf("PeakWorkingSetSize(K):t %-8dt",pSystemProc->VmCounters.PeakWorkingSetSize/1024);
printf("WorkingSetSize(K):t%-8dn",pSystemProc->VmCounters.WorkingSetSize/1024);
推荐阅读
- Windows2003 远程桌面超过最大连接数解决办法
- win2003 sql 1433 端口连接问题
- Windows 2003系统加速十四招大法
- 为Windows 2003加装视频压缩
- Win 2003系统网络负载均衡的实现
- Windows 2003优化配置
- 变Win 2003为工作站
- 配置基于Win 2003 的服务器
- Win2003下提高FSO的安全性
- Win 2003系统十例最新配置技巧
