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