如何得到系统的负荷情况和某一进程占用的cpu时间(100分)

  • 主题发起人 主题发起人 johnsun
  • 开始时间 开始时间
J

johnsun

Unregistered / Unconfirmed
GUEST, unregistred user!
我想当系统中某一进程的cpu时间&gt;90时就kill它<br>急,请不吝赐教!
 
翻翻API函数吧,象WINDOWS任务管理器那样的功能应该时可以做的。
 
我知道可以实现的,但我要的时具体的函数及用法!!
 
在注册表是有
 
没人知道吗?
 
http://www.delphibbs.com/delphibbs/dispq.asp?lid=565450
 
转一个<br><br>问题提出/摘要:<br>从注册表获取如活动进程数、CPU占用率等信息? <br>&nbsp;<br><br>回答:<br>&nbsp; 在注册表中,有一个分支叫HKEY_DYN_DATA,大量的系统信息都保存在此分支下的PerfStats主键中。<br>&nbsp; <br>&nbsp; 为了获取如CPU的使用率等信息,你需要做三件事:<br>&nbsp; <br>&nbsp; 第一步是开始选择的计数器,可以通过读取相应的注册表主键完成。<br>&nbsp; <br>&nbsp; 例如:<br>&nbsp; 如果我们想知道CPU的占用率,你可以读HKEY_DYN_DATA的这个主键<br>&nbsp; 'PerfStats/StartStat/KERNEL/CPUusage' <br>&nbsp; 这一步是开始计数器<br>&nbsp; <br>&nbsp; 下一步是是读取'PerfStats/StatData/KERNEL/CPUusage'的值,它的值给出了当前CPU的使用率。如果我们将代码放在一个Timer的事件中,我们就可以看到动态的变化了。<br>&nbsp; <br>&nbsp; 最后一步是停止计数器,通过读取注册表的'PerfStats/StopStat/KERNEL/CPUusage'键完成。<br>&nbsp; <br>&nbsp; 除CPU的占用率外,这里还有很多其它的计数器。你可以打开用注册表编辑器打开PerfStats/StatData键,可以看到全部的列表。<br>&nbsp; <br>&nbsp; 我生成了一个构件来获取注册表HKEY_DYN_DATA分支提供的所有计数的值。以下是代码:<br>&nbsp; <br>&nbsp; unit SystemInfo; <br>&nbsp; <br>&nbsp; interface <br>&nbsp; <br>&nbsp; uses <br>&nbsp; &nbsp; Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, <br>&nbsp; &nbsp; Dialogs,extctrls; <br>&nbsp; <br>&nbsp; type TDialupAdapterInfo = record //Information of Dialup adapter <br>&nbsp; &nbsp; alignment:dword; <br>&nbsp; &nbsp; buffer:dword; <br>&nbsp; &nbsp; bytesrecieved:dword; <br>&nbsp; &nbsp; bytesXmit:dword; <br>&nbsp; &nbsp; ConnectSpeed:dword; <br>&nbsp; &nbsp; CRC:dword; <br>&nbsp; &nbsp; framesrecieved:dword; <br>&nbsp; &nbsp; FramesXmit:dword; <br>&nbsp; &nbsp; Framing:dword; <br>&nbsp; &nbsp; runts:dword; <br>&nbsp; &nbsp; Overrun:dword; <br>&nbsp; &nbsp; timeout:dword; <br>&nbsp; &nbsp; totalbytesrecieved:dword; <br>&nbsp; &nbsp; totalbytesXmit:dword; <br>&nbsp; end; <br>&nbsp; <br>&nbsp; type TKernelInfo = record <br>&nbsp; &nbsp; CpuUsagePcnt:dword; <br>&nbsp; &nbsp; Numthreads:dword; <br>&nbsp; &nbsp; NumVMS:dword; <br>&nbsp; end; <br>&nbsp; <br>&nbsp; type TVCACHEInfo = record <br>&nbsp; &nbsp; ccurpages:dword; <br>&nbsp; &nbsp; cMacPages:dword; <br>&nbsp; &nbsp; cminpages:dword; <br>&nbsp; &nbsp; FailedRecycles:dword; <br>&nbsp; &nbsp; Hits:dword; <br>&nbsp; &nbsp; LRUBuffers:dword; <br>&nbsp; &nbsp; LRURecycles:dword; <br>&nbsp; &nbsp; Misses:dword; <br>&nbsp; &nbsp; RandomRecycles:dword; <br>&nbsp; end; <br>&nbsp; <br>&nbsp; type TFATInfo = record <br>&nbsp; &nbsp; BreadsSec:dword; <br>&nbsp; &nbsp; BwritesSec:dword; <br>&nbsp; &nbsp; Dirtydata:dword; <br>&nbsp; &nbsp; ReadsSec:dword; <br>&nbsp; &nbsp; WritesSec:dword; <br>&nbsp; end; <br>&nbsp; <br>&nbsp; type TVMMInfo = record <br>&nbsp; &nbsp; CDiscards:dword; <br>&nbsp; &nbsp; CInstancefaults:dword; <br>&nbsp; &nbsp; CPageFaults:dword; <br>&nbsp; &nbsp; cPageIns:dword; <br>&nbsp; &nbsp; cPageOuts:dword; <br>&nbsp; &nbsp; cpgCommit:dword; <br>&nbsp; &nbsp; cpgDiskCache:dword; <br>&nbsp; &nbsp; cpgDiskCacheMac:dword; <br>&nbsp; &nbsp; cpgDiskCacheMid:dword; <br>&nbsp; &nbsp; cpgDiskCacheMin:dword; <br>&nbsp; &nbsp; cpgfree:dword; <br>&nbsp; <br>&nbsp; &nbsp; cpglocked:dword; <br>&nbsp; &nbsp; cpglockedNoncache:dword; <br>&nbsp; &nbsp; cpgother:dword; <br>&nbsp; &nbsp; cpgsharedpages:dword; <br>&nbsp; &nbsp; cpgswap:dword; <br>&nbsp; &nbsp; cpgswapfile:dword; <br>&nbsp; &nbsp; cpgswapfiledefective:dword; <br>&nbsp; &nbsp; cpgswapfileinuse:dword; <br>&nbsp; end; <br>&nbsp; <br>&nbsp; type <br>&nbsp; &nbsp; TSysInfo = class(TComponent) <br>&nbsp; &nbsp; private <br>&nbsp; &nbsp; &nbsp;fDialupAdapterInfo:TDialupAdapterInfo; <br>&nbsp; &nbsp; &nbsp;fKernelInfo:TKernelInfo; <br>&nbsp; &nbsp; &nbsp;fVCACHEInfo:TVCACHEInfo; <br>&nbsp; &nbsp; &nbsp;fFATInfo:TFATInfo; <br>&nbsp; &nbsp; &nbsp;fVMMInfo:TVMMInfo; <br>&nbsp; &nbsp; &nbsp;ftimer:TTimer; <br>&nbsp; &nbsp; &nbsp;fupdateinterval:integer; <br>&nbsp; &nbsp; &nbsp;tmp:dword; <br>&nbsp; &nbsp; &nbsp;vsize:dword; <br>&nbsp; &nbsp; &nbsp;pkey:hkey; <br>&nbsp; &nbsp; &nbsp;regtype:pdword; <br>&nbsp; &nbsp; &nbsp;fstopped:boolean; <br>&nbsp; &nbsp; &nbsp;procedure fupdatinginfo(sender:tobject); <br>&nbsp; &nbsp; &nbsp;procedure fsetupdateinterval(aupdateinterval:integer); <br>&nbsp; &nbsp; protected <br>&nbsp; &nbsp; &nbsp;fsysInfoChanged:TNotifyEvent; <br>&nbsp; &nbsp; public <br>&nbsp; &nbsp; &nbsp;constructor Create(Aowner:Tcomponent);override; <br>&nbsp; &nbsp; &nbsp;destructor &nbsp;Destroy;override; <br>&nbsp; <br>&nbsp; &nbsp; &nbsp;property DialupAdapterInfo: TDialupAdapterInfo read fDialupAdapterInfo; <br>&nbsp; &nbsp; &nbsp;property KernelInfo: TKernelInfo read fKernelInfo; <br>&nbsp; &nbsp; &nbsp;property VCACHEInfo: TVCACHEInfo read fVCACHEInfo; <br>&nbsp; &nbsp; &nbsp;property FATInfo: TFATInfo read fFATInfo; <br>&nbsp; &nbsp; &nbsp;property VMMInfo: TVMMInfo read fVMMInfo; <br>&nbsp; &nbsp; &nbsp;procedure StartRecievingInfo; <br>&nbsp; &nbsp; &nbsp;procedure StopRecievingInfo; <br>&nbsp; &nbsp; published <br>&nbsp; &nbsp; &nbsp;property SysInfoChanged:TNotifyEvent read fsysInfoChanged write <br>&nbsp; &nbsp; &nbsp; fsysInfoChanged;//this event is called after a specific interval. <br>&nbsp; &nbsp; &nbsp;property UpdateInterval:integer read fupdateInterval write <br>&nbsp; &nbsp; &nbsp; fsetupdateinterval default 5000; <br>&nbsp; &nbsp; end; <br>&nbsp; <br>&nbsp; procedure Register; <br>&nbsp; <br>&nbsp; implementation <br>&nbsp; <br>&nbsp; constructor TSysInfo.Create(Aowner:Tcomponent); <br>&nbsp; begin <br>&nbsp; inherited; <br>&nbsp; ftimer:=ttimer.Create(self); <br>&nbsp; ftimer.enabled:=false; <br>&nbsp; ftimer.OnTimer:=fupdatinginfo; <br>&nbsp; vsize:=4; <br>&nbsp; fstopped:=true; <br>&nbsp; end; <br>&nbsp; <br>&nbsp; procedure TSysInfo.startrecievingInfo; <br>&nbsp; var <br>&nbsp; res:integer; <br>&nbsp; begin <br>&nbsp; res:=RegOpenKeyEx(HKEY_DYN_DATA,'PerfStats/StartStat',0,KEY_ALL_ACCESS,pkey); <br>&nbsp; if res&lt;&gt;0 then <br>&nbsp; &nbsp; raise exception.Create('Could not open registry key'); <br>&nbsp; fstopped:=false; <br>&nbsp; // For Dial Up Adapter <br>&nbsp; RegQueryValueEx(pkey,'Dial-Up Adapter/Alignment',nil,regtype,@tmp,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'Dial-Up Adapter/Buffer',nil,regtype,@tmp,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'Dial-Up Adapter/Framing',nil,regtype,@tmp,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'Dial-Up Adapter/Overrun ',nil,regtype,@tmp,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'Dial-Up Adapter/Timeout',nil,regtype,@tmp,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'Dial-Up Adapter/CRC',nil,regtype,@tmp,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'Dial-Up Adapter/Runts',nil,regtype,@tmp,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'Dial-Up Adapter/FramesXmit',nil,regtype,@tmp,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'Dial-Up Adapter/FramesRecvd',nil,regtype,@tmp,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'Dial-Up Adapter/BytesXmit',nil,regtype,@tmp,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'Dial-Up Adapter/BytesRecvd',nil,regtype,@tmp,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'Dial-Up Adapter/TotalBytesXmit',nil,regtype,@tmp,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'Dial-Up Adapter/TotalBytesRecvd',nil,regtype,@tmp,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'Dial-Up Adapter/ConnectSpeed',nil,regtype,@tmp,@vsize); <br>&nbsp; <br>&nbsp; // For VCACHE <br>&nbsp; RegQueryValueEx(pkey,'VCACHE/LRUBuffers',nil,regtype,@tmp,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VCACHE/FailedRecycles',nil,regtype,@tmp,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VCACHE/RandomRecycles',nil,regtype,@tmp,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VCACHE/LRURecycles',nil,regtype,@tmp,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VCACHE/Misses',nil,regtype,@tmp,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VCACHE/Hits',nil,regtype,@tmp,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VCACHE/cMacPages',nil,regtype,@tmp,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VCACHE/cMinPages',nil,regtype,@tmp,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VCACHE/cCurPages',nil,regtype,@tmp,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'Dial-Up Adapter/BytesXmit',nil,regtype,@tmp,@vsize); <br>&nbsp; <br>&nbsp; //For VFAT <br>&nbsp; <br>&nbsp; RegQueryValueEx(pkey,'VFAT/DirtyData',nil,regtype,@tmp,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VFAT/BReadsSec',nil,regtype,@tmp,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VFAT/BWritesSec',nil,regtype,@tmp,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VFAT/ReadsSec',nil,regtype,@tmp,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VFAT/WritesSec',nil,regtype,@tmp,@vsize); <br>&nbsp; //For VMM <br>&nbsp; <br>&nbsp; RegQueryValueEx(pkey,'VMM/cpgLockedNoncache',nil,regtype,@tmp,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VMM/cpgCommit',nil,regtype,@tmp,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VMM/cpgSharedPages',nil,regtype,@tmp,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VMM/cpgDiskcacheMid',nil,regtype,@tmp,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VMM/cpgDiskcacheMac',nil,regtype,@tmp,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VMM/cpgDiskcacheMin',nil,regtype,@tmp,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VMM/cpgDiskcache',nil,regtype,@tmp,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VMM/cpgSwapfileDefective',nil,regtype,@tmp,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VMM/cpgSwapfileInUse',nil,regtype,@tmp,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VMM/cpgSwapfile',nil,regtype,@tmp,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VMM/cDiscards',nil,regtype,@tmp,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VMM/cPageOuts',nil,regtype,@tmp,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VMM/cPageIns',nil,regtype,@tmp,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VMM/cInstanceFaults',nil,regtype,@tmp,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VMM/cPageFaults',nil,regtype,@tmp,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VMM/cpgOther',nil,regtype,@tmp,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VMM/cpgSwap',nil,regtype,@tmp,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VMM/cpgLocked',nil,regtype,@tmp,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VMM/cpgFree',nil,regtype,@tmp,@vsize); <br>&nbsp; //For KERNEL <br>&nbsp; RegQueryValueEx(pkey,'KERNEL/CPUUsage',nil,regtype,@tmp,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'KERNEL/VMs',nil,regtype,@tmp,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'KERNEL/Threads',nil,regtype,@tmp,@vsize); <br>&nbsp; RegCloseKey(pkey); <br>&nbsp; ftimer.enabled:=true; <br>&nbsp; end; <br>&nbsp; <br>&nbsp; procedure tsysinfo.fupdatinginfo(sender:tobject); <br>&nbsp; var <br>&nbsp; res:integer; <br>&nbsp; begin <br>&nbsp; res:=RegOpenKeyEx(HKEY_DYN_DATA,'PerfStats/StatData',0,KEY_ALL_ACCESS,pkey); <br>&nbsp; if res&lt;&gt;0 then <br>&nbsp; &nbsp; raise exception.Create('Could not open registry key'); <br>&nbsp; //For Dial Up Adapter <br>&nbsp; RegQueryValueEx(pkey,'Dial-Up Adapter/Alignment',nil,regtype,@fDialupAdapterInfo.alignment,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'Dial-Up Adapter/Buffer',nil,regtype,@fDialupAdapterInfo.buffer,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'Dial-Up Adapter/Framing',nil,regtype,@fDialupAdapterInfo.framing,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'Dial-Up Adapter/Overrun ',nil,regtype,@fDialupAdapterInfo.overrun,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'Dial-Up Adapter/Timeout',nil,regtype,@fDialupAdapterInfo.timeout,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'Dial-Up Adapter/CRC',nil,regtype,@fDialupAdapterInfo.crc,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'Dial-Up Adapter/Runts',nil,regtype,@fDialupAdapterInfo.runts,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'Dial-Up Adapter/FramesXmit',nil,regtype,@fDialupAdapterInfo.framesxmit,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'Dial-Up Adapter/FramesRecvd',nil,regtype,@fDialupAdapterInfo.framesrecieved,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'Dial-Up Adapter/BytesXmit',nil,regtype,@fDialupAdapterInfo.bytesxmit,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'Dial-Up Adapter/BytesRecvd',nil,regtype,@fDialupAdapterInfo.bytesrecieved,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'Dial-Up Adapter/TotalBytesXmit',nil,regtype,@fDialupAdapterInfo.totalbytesxmit,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'Dial-Up Adapter/TotalBytesRecvd',nil,regtype,@fDialupAdapterInfo.totalbytesrecieved,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'Dial-Up Adapter/ConnectSpeed',nil,regtype,@fDialupAdapterInfo.connectspeed,@vsize); <br>&nbsp; // For VCACHE <br>&nbsp; RegQueryValueEx(pkey,'VCACHE/LRUBuffers',nil,regtype,@fVCACHEInfo.lrubuffers,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VCACHE/FailedRecycles',nil,regtype,@fVCACHEInfo.failedrecycles,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VCACHE/RandomRecycles',nil,regtype,@fVCACHEInfo.randomrecycles,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VCACHE/LRURecycles',nil,regtype,@fVCACHEInfo.lrurecycles,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VCACHE/Misses',nil,regtype,@fVCACHEInfo.misses,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VCACHE/Hits',nil,regtype,@fVCACHEInfo.hits,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VCACHE/cMacPages',nil,regtype,@fVCACHEInfo.cmacpages,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VCACHE/cMinPages',nil,regtype,@fVCACHEInfo.cminpages,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VCACHE/cCurPages',nil,regtype,@fVCACHEInfo.ccurpages,@vsize); <br>&nbsp; //For VFAT <br>&nbsp; RegQueryValueEx(pkey,'VFAT/DirtyData',nil,regtype,@ffatinfo.dirtydata,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VFAT/BReadsSec',nil,regtype,@ffatinfo.breadssec,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VFAT/BWritesSec',nil,regtype,@ffatinfo.bwritessec,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VFAT/ReadsSec',nil,regtype,@ffatinfo.readssec,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VFAT/WritesSec',nil,regtype,@ffatinfo.writessec,@vsize); <br>&nbsp; //For VMM <br>&nbsp; RegQueryValueEx(pkey,'VMM/cpgLockedNoncache',nil,regtype,@fvmminfo.cpglockednoncache,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VMM/cpgCommit',nil,regtype,@fvmminfo.cpgcommit,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VMM/cpgSharedPages',nil,regtype,@fvmminfo.cpgsharedpages,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VMM/cpgDiskcacheMid',nil,regtype,@fvmminfo.cpgdiskcacheMid,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VMM/cpgDiskcacheMac',nil,regtype,@fvmminfo.cpgdiskcacheMac,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VMM/cpgDiskcacheMin',nil,regtype,@fvmminfo.cpgdiskcacheMin,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VMM/cpgDiskcache',nil,regtype,@fvmminfo.cpgdiskcache,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VMM/cpgSwapfileDefective',nil,regtype,@fvmminfo.cpgswapfiledefective,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VMM/cpgSwapfileInUse',nil,regtype,@fvmminfo.cpgswapfileinuse,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VMM/cpgSwapfile',nil,regtype,@fvmminfo.cpgswapfile,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VMM/cDiscards',nil,regtype,@fvmminfo.cdiscards,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VMM/cPageOuts',nil,regtype,@fvmminfo.cpageouts,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VMM/cPageIns',nil,regtype,@fvmminfo.cpageins,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VMM/cInstanceFaults',nil,regtype,@fvmminfo.cinstancefaults,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VMM/cPageFaults',nil,regtype,@fvmminfo.cpagefaults,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VMM/cpgOther',nil,regtype,@fvmminfo.cpgother,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VMM/cpgSwap',nil,regtype,@fvmminfo.cpgswap,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VMM/cpgLocked',nil,regtype,@fvmminfo.cpglocked,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'VMM/cpgFree',nil,regtype,@fvmminfo.cpgfree,@vsize); <br>&nbsp; //For KERNEL <br>&nbsp; RegQueryValueEx(pkey,'KERNEL/CPUUsage',nil,regtype,@fkernelinfo.cpuusagepcnt,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'KERNEL/VMs',nil,regtype,@fkernelinfo.numvms,@vsize); <br>&nbsp; RegQueryValueEx(pkey,'KERNEL/Threads',nil,regtype,@fkernelinfo.numThreads,@vsize); <br>&nbsp; RegCloseKey(pkey); <br>&nbsp; if assigned(SysInfoChanged) then <br>&nbsp; &nbsp; SysInfoChanged(self); <br>&nbsp; end; <br>&nbsp; <br>&nbsp; procedure TSysInfo.stoprecievingInfo; <br>&nbsp; var <br>&nbsp; res:integer; <br>&nbsp; begin <br>&nbsp; res:=RegOpenKeyEx(HKEY_DYN_DATA,'PerfStats/StopStat',0,KEY_ALL_ACCESS,pkey); <br>&nbsp; if not fstopped then <br>&nbsp; &nbsp; begin <br>&nbsp; &nbsp; &nbsp;if res&lt;&gt;0 then <br>&nbsp; &nbsp; &nbsp; raise exception.Create('Could not open registry key'); <br>&nbsp; &nbsp; &nbsp;//For Dial Up Adapter <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'Dial-Up Adapter/Alignment',nil,regtype,@tmp,@vsize); <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'Dial-Up Adapter/Buffer',nil,regtype,@tmp,@vsize); <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'Dial-Up Adapter/Framing',nil,regtype,@tmp,@vsize); <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'Dial-Up Adapter/Overrun ',nil,regtype,@tmp,@vsize); <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'Dial-Up Adapter/Timeout',nil,regtype,@tmp,@vsize); <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'Dial-Up Adapter/CRC',nil,regtype,@tmp,@vsize); <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'Dial-Up Adapter/Runts',nil,regtype,@tmp,@vsize); <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'Dial-Up Adapter/FramesXmit',nil,regtype,@tmp,@vsize); <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'Dial-Up Adapter/FramesRecvd',nil,regtype,@tmp,@vsize); <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'Dial-Up Adapter/BytesXmit',nil,regtype,@tmp,@vsize); <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'Dial-Up Adapter/BytesRecvd',nil,regtype,@tmp,@vsize); <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'Dial-Up Adapter/TotalBytesXmit',nil,regtype,@tmp,@vsize); <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'Dial-Up Adapter/TotalBytesRecvd',nil,regtype,@tmp,@vsize); <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'Dial-Up Adapter/ConnectSpeed',nil,regtype,@tmp,@vsize); <br>&nbsp; <br>&nbsp; &nbsp; &nbsp;// For VCACHE <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'VCACHE/LRUBuffers',nil,regtype,@tmp,@vsize); <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'VCACHE/FailedRecycles',nil,regtype,@tmp,@vsize); <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'VCACHE/RandomRecycles',nil,regtype,@tmp,@vsize); <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'VCACHE/LRURecycles',nil,regtype,@tmp,@vsize); <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'VCACHE/Misses',nil,regtype,@tmp,@vsize); <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'VCACHE/Hits',nil,regtype,@tmp,@vsize); <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'VCACHE/cMacPages',nil,regtype,@tmp,@vsize); <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'VCACHE/cMinPages',nil,regtype,@tmp,@vsize); <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'VCACHE/cCurPages',nil,regtype,@tmp,@vsize); <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'Dial-Up Adapter/BytesXmit',nil,regtype,@tmp,@vsize); <br>&nbsp; <br>&nbsp; &nbsp; &nbsp;//For VFAT <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'VFAT/DirtyData',nil,regtype,@tmp,@vsize); <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'VFAT/BReadsSec',nil,regtype,@tmp,@vsize); <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'VFAT/BWritesSec',nil,regtype,@tmp,@vsize); <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'VFAT/ReadsSec',nil,regtype,@tmp,@vsize); <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'VFAT/WritesSec',nil,regtype,@tmp,@vsize); <br>&nbsp; <br>&nbsp; &nbsp; &nbsp;//For VMM <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'VMM/cpgLockedNoncache',nil,regtype,@tmp,@vsize); <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'VMM/cpgCommit',nil,regtype,@tmp,@vsize); <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'VMM/cpgSharedPages',nil,regtype,@tmp,@vsize); <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'VMM/cpgDiskcacheMid',nil,regtype,@tmp,@vsize); <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'VMM/cpgDiskcacheMac',nil,regtype,@tmp,@vsize); <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'VMM/cpgDiskcacheMin',nil,regtype,@tmp,@vsize); <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'VMM/cpgDiskcache',nil,regtype,@tmp,@vsize); <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'VMM/cpgSwapfileDefective',nil,regtype,@tmp,@vsize); <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'VMM/cpgSwapfileInUse',nil,regtype,@tmp,@vsize); <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'VMM/cpgSwapfile',nil,regtype,@tmp,@vsize); <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'VMM/cDiscards',nil,regtype,@tmp,@vsize); <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'VMM/cPageOuts',nil,regtype,@tmp,@vsize); <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'VMM/cPageIns',nil,regtype,@tmp,@vsize); <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'VMM/cInstanceFaults',nil,regtype,@tmp,@vsize); <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'VMM/cPageFaults',nil,regtype,@tmp,@vsize); <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'VMM/cpgOther',nil,regtype,@tmp,@vsize); <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'VMM/cpgSwap',nil,regtype,@tmp,@vsize); <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'VMM/cpgLocked',nil,regtype,@tmp,@vsize); <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'VMM/cpgFree',nil,regtype,@tmp,@vsize); <br>&nbsp; <br>&nbsp; &nbsp; &nbsp;//For KERNEL <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'KERNEL/CPUUsage',nil,regtype,@tmp,@vsize); <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'KERNEL/VMs',nil,regtype,@tmp,@vsize); <br>&nbsp; &nbsp; &nbsp;RegQueryValueEx(pkey,'KERNEL/Threads',nil,regtype,@tmp,@vsize); <br>&nbsp; <br>&nbsp; &nbsp; &nbsp;RegCloseKey(pkey); <br>&nbsp; &nbsp; &nbsp;ftimer.enabled:=false; <br>&nbsp; &nbsp; &nbsp;fstopped:=true; <br>&nbsp; &nbsp; end; <br>&nbsp; end; <br>&nbsp; <br>&nbsp; procedure tsysinfo.fsetupdateinterval(aupdateinterval:integer); <br>&nbsp; begin <br>&nbsp; if (ftimer&lt;&gt;nil) and(aupdateinterval&gt;0) then <br>&nbsp; &nbsp; begin <br>&nbsp; &nbsp; ftimer.Interval:=aupdateinterval; <br>&nbsp; &nbsp; fupdateinterval:=aupdateinterval; <br>&nbsp; end; <br>&nbsp; if (ftimer&lt;&gt;nil) and(aupdateinterval=0) then <br>&nbsp; begin <br>&nbsp; &nbsp; ftimer.Interval:=500; <br>&nbsp; &nbsp; fupdateinterval:=500; <br>&nbsp; end; <br>&nbsp; <br>&nbsp; end; <br>&nbsp; <br>&nbsp; destructor tsysinfo.Destroy; <br>&nbsp; begin <br>&nbsp; StopRecievingInfo; <br>&nbsp; ftimer.Destroy; <br>&nbsp; inherited; <br>&nbsp; end; <br>&nbsp; <br>&nbsp; procedure Register; <br>&nbsp; begin <br>&nbsp; &nbsp; RegisterComponents('Samples', [TSysInfo]); <br>&nbsp; end; <br><br>&nbsp;<br>
 
多人接受答案了。
 
后退
顶部