电脑教程中文网
首页  动态网站建设学习 程序  笑话  论坛 娱乐  交友 ADSL  峄城  成功者
中文名:电脑教程中文网,收集了大量的电脑教程! 编程技术文档 游戏开发 笑话站暂时关闭 设为首页
网页设计 HTML | Dreamweaver | CSS | Firework | FrontPage WEB开发 ASP | JSP | PHP | .NET | CGI | JS | VBS | XML | IIS6 | Apache | PWS
程序设计 Java | C++ |VC++ | C# | Delphi | VB | C语言 | 汇编 | Pascal | Perl 数据库 MSSQL | MySQL | Access | VF | Oracle | DB2 | SYBASE |
办公软件 Word | Excel | WPS | PowerPoint 动画平面 Photoshop | ACDSee | 3Dmax | Flash | Coreldraw |
操作系统 Windows 2000 | Windows XP | Windows 2003 | SCO Unix | Windows Vista | unix、Linux | 综合| 服务器 | 系统安全| 黑客技术
其  他 UltraDev | DOS | UML | PWS | Powerbuilder | 开发心得 | 设计理念 | 病毒库 | 其他 | LightTPD (分类排序给您带来不便请谅解)
推  荐: Java文档500篇》《ASP.NET与相关数据库技术高级指南》《TC图形函数详解》《C函数速查手册》《C语言编程宝典之一》《MFC深入浅出》《黑客零起点》《VC++ 编程指南》《JScript 用户指南》 《CSS教程宝典》《Microsoft Jet SQL 参考》《delphi技巧集合》《MySQL 4.1.0 中文参考手册》《MySQL中文手册
【导航】 您现在的位置 : 首页 - Server教程 - 《服务器技术文档 - 高级教程篇》- 探测Win2K/XP/2003本机系统信息(6)

探测Win2K/XP/2003本机系统信息(6)

日期:2005-7-10 10:06:39    作者:TOo2y   人气:   来源:MBsky




__try
{
hNtDll = LoadLibrary("NtDll.dll");
     if(hNtDll == NULL)
{
     printf("LoadLibrary Error: %d\n",GetLastError());
     __leave;
}

NtQuerySystemInformation = (NTQUERYSYSTEMINFORMATION)GetProcAddress(hNtDll,"NtQuerySystemInformation");
if(NtQuerySystemInformation == NULL)
{
printf("GetProcAddress for NtQuerySystemInformation Error: %d\n",GetLastError());
__leave;
}

dwNumberBytes = sizeof(SYSTEM_PROCESSOR_TIMES);
NtQuerySystemInformation = (NTQUERYSYSTEMINFORMATION)GetProcAddress(hNtDll,"NtQuerySystemInformation");
if(NtQuerySystemInformation == NULL)
{
printf("GetProcAddress Error: %d\n",GetLastError());
__leave;
}

Status = NtQuerySystemInformation(SYSTEM_PROC_TIME,
               &SystemProcTime,
dwNumberBytes,
&dwReturnLength);
if(Status != STATUS_SUCCESS)
{
printf("NtQuerySystemInformation for Processor Time Error: %d\n",GetLastError());
__leave;
}

printf("IdleTime:\t\t");
llTempTime  = SystemProcTime.IdleTime.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("%.3d\n",llTempTime);

printf("KernelTime:\t\t");
llTempTime  = SystemProcTime.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("%.3d\n",llTempTime);

printf("UserTime:\t\t");
llTempTime  = SystemProcTime.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("%.3d\n",llTempTime);

printf("DpcTime:\t\t");
llTempTime  = SystemProcTime.DpcTime.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("%.3d\n",llTempTime);

printf("InterruptTime:\t\t");
llTempTime  = SystemProcTime.InterruptTime.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("%.3d\n",llTempTime);

printf("InterruptCount:\t\t%d\n",SystemProcTime.InterruptCount);

}
__finally
{
if(hNtDll != NULL)
{
FreeLibrary(hNtDll);
}
}

return 0;
}

DWORD PagefileInfo()
{
PSYSTEM_PAGEFILE_INFORMATION   pSystemPagefileInfo;
PVOID              pBuffer;
HMODULE            hNtDll = NULL;
DWORD              dwNumberBytes;
DWORD              dwReturnLength;
     NTSTATUS             Status;

__try
{
hNtDll = LoadLibrary("NtDll.dll");
     if(hNtDll == NULL)
{
     printf("LoadLibrary Error: %d\n",GetLastError());
    __leave;
}

NtQuerySystemInformation = (NTQUERYSYSTEMINFORMATION)GetProcAddress(hNtDll,"NtQuerySystemInformation");
if(NtQuerySystemInformation == NULL)
{
printf("GetProcAddress for NtQuerySystemInformation Error: %d\n",GetLastError());
__leave;
}

dwNumberBytes = MAX_INFO_BUF_LEN;
pBuffer = (LPVOID)malloc(dwNumberBytes);
Status  = NtQuerySystemInformation(SYSTEM_PAGE_INFO,
              pBuffer,
dwNumberBytes,
&dwReturnLength);
if(Status != STATUS_SUCCESS)
{
printf("NtQuerySystemInformation for Pagefile Error: %d\n",GetLastError());
__leave;
}

pSystemPagefileInfo = (PSYSTEM_PAGEFILE_INFORMATION)pBuffer;
do
{
printf("CurrentPagefileSize:\t%d\n",pSystemPagefileInfo->CurrentSize);
printf("TotalPagefileUsed:\t%d\n",pSystemPagefileInfo->TotalUsed);
printf("PeakPagefileUsed:\t%d\n",pSystemPagefileInfo->PeakUsed);
wprintf(L"PagefileFileName:\t%s\n",pSystemPagefileInfo->FileName.Buffer);

pSystemPagefileInfo = (PSYSTEM_PAGEFILE_INFORMATION)((char *)pBuffer + pSystemPagefileInfo->NetxEntryOffset);
}while(pSystemPagefileInfo->NetxEntryOffset != 0);
}
__finally
{
if(pBuffer != NULL)
{
free(pBuffer);
}
if(hNtDll  != NULL)
{
FreeLibrary(hNtDll);
}
}

return 0;
}

DWORD CacheInfo()
{
SYSTEM_CACHE_INFORMATION     SystemCacheInfo;
HMODULE            hNtDll = NULL;
DWORD              dwNumberBytes;
DWORD              dwReturnLength;
     NTSTATUS             Status;

__try
{
hNtDll = LoadLibrary("NtDll.dll");
     if(hNtDll == NULL)
{
    printf("LoadLibrary Error: %d\n",GetLastError());
     __leave;
}

NtQuerySystemInformation = (NTQUERYSYSTEMINFORMATION)GetProcAddress(hNtDll,"NtQuerySystemInformation");
if(NtQuerySystemInformation == NULL)
{
printf("GetProcAddress for NtQuerySystemInformation Error: %d\n",GetLastError());
__leave;
}

dwNumberBytes = sizeof(SYSTEM_CACHE_INFORMATION);
Status  = NtQuerySystemInformation(SYSTEM_CACHE_INFO,
                &SystemCacheInfo,
dwNumberBytes,
&dwReturnLength);
if(Status != STATUS_SUCCESS)
{
printf("NtQuerySystemInformation for Cache Error: %d\n",GetLastError());
__leave;
}

printf("CacheWorkingSetSize:\t\t%d(KB)\n",SystemCacheInfo.SystemCacheWsSize/1024);
printf("CacheWorkingSetPeakSize:\t%d(KB)\n",SystemCacheInfo.SystemCacheWsPeakSize/1024);
printf("CacheWorkingSetFaults:\t\t%d\n",SystemCacheInfo.SystemCacheWsFaults);
printf("CacheWorkingSetMinimum:\t\t%d\n",SystemCacheInfo.SystemCacheWsMinimum);
printf("CacheWorkingSetMaximum:\t\t%d\n",SystemCacheInfo.SystemCacheWsMaximum);
printf("TransitionSharedPages:\t\t%d\n",SystemCacheInfo.TransitionSharedPages);
printf("TransitionSharedPagesPeak:\t%d\n",SystemCacheInfo.TransitionSharedPagesPeak);

}
__finally
{
if(hNtDll != NULL)
{
FreeLibrary(hNtDll);
}
}

return 0;
}

VOID Start()
{
printf("T-PMPerf, by TOo2y\n");
printf("E-mail: TOo2y@safechina.net\n");
printf("HomePage: www.safechina.net\n");
printf("Date: 05-09-2003\n\n");
return ;
}

VOID Usage()
{
printf("Usage:\tT-PMPerf <Option>\n");
printf("Option:\n");
printf("  -Perf   System Performance Information\n");
printf("  -Proc   System Processor Information\n");
printf("  -Page   System Pagefile Information\n");
printf("  -Cache  System Cache Information\n");
return ;
}

#endif

Reference:


www.CLDE.net




网站首页 - 友情链接 - 公司简介 - 联系方式 - 广告投放 - 客户服务 - 错误报告 - 免责声明 - About us
CLDE.NET电脑教程中文网版权所有 未经许可禁止镜象和复制本站资料 MSN:CLDE_NET@hotmail.com
技术支持:CLDE.NET信息中心 鲁ICP备05039940号 友情链接QQ:784079(隐)