如何监测cpu和内存的使用情况(代码),急(100)相送 如何监测cpu和内存的使用情况(代码),急(100)相送,象任务管理器中的那样曲线,曲线可以用paintbox画出来,数据怎么样取回????尽快揭帖 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 得到是用API,GETSYSTEMINFO,至于画线就自己画好了,数据得到了,那个还不好办?加个TIMER CSDN 怎么啦?我想给你发个程序也发不出去不好意思 用TChart组件显示内存使用情况:chart组件为:Bar类型unit Main;interfaceuses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, TeEngine, Series, ExtCtrls, TeeProcs, Chart, Buttons;type TMainForm = class(TForm) Chart1: TChart; Button1: TButton; Series1: TBarSeries; BitBtn1: TBitBtn; Label1: TLabel; procedure Button1Click(Sender: TObject); procedure BitBtn1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;var MainForm: TMainForm;implementation{$R *.DFM}var HeapStatus: THeapStatus;procedure TMainForm.Button1Click(Sender: TObject);begin HeapStatus := System.GetHeapStatus; with Series1, HeapStatus do begin Add(TotalCommitted, 'Total Committed', clTeeColor); Add(TotalAllocated, 'Total Allocated', clTeeColor); Add(TotalFree, 'Total Free', clTeeColor); Add(FreeSmall, 'Free Small', clTeeColor); Add(FreeBig, 'Free Big', clTeeColor); Add(Unused, 'Unused', clTeeColor); Add(Overhead, 'Overhead', clTeeColor); end;end;procedure TMainForm.BitBtn1Click(Sender: TObject);beginclose;end;end. lihao_ningxia(耗子) 这个程序我没有作过,请不吝给点代码谢谢 How to get the CPU usage in percentconstSystemBasicInformation = 0;SystemPerformanceInformation = 2;SystemTimeInformation = 3;typeTPDWord = ^DWORD;TSystem_Basic_Information = packed recorddwUnknown1: DWORD;uKeMaximumIncrement: ULONG;uPageSize: ULONG;uMmNumberOfPhysicalPages: ULONG;uMmLowestPhysicalPage: ULONG;uMmHighestPhysicalPage: ULONG;uAllocationGranularity: ULONG;pLowestUserAddress: Pointer;pMmHighestUserAddress: Pointer;uKeActiveProcessors: ULONG;bKeNumberProcessors: byte;bUnknown2: byte;wUnknown3: word;end;typeTSystem_Performance_Information = packed recordliIdleTime: LARGE_INTEGER; {LARGE_INTEGER}dwSpare: array[0..75] of DWORD;end;typeTSystem_Time_Information = packed recordliKeBootTime: LARGE_INTEGER;liKeSystemTime: LARGE_INTEGER;liExpTimeZoneBias: LARGE_INTEGER;uCurrentTimeZoneId: ULONG;dwReserved: DWORD;end;varNtQuerySystemInformation: function(infoClass: DWORD;buffer: Pointer;bufSize: DWORD;returnSize: TPDword): DWORD; stdcall = nil; liOldIdleTime: LARGE_INTEGER = ();liOldSystemTime: LARGE_INTEGER = ();function Li2Double(x: LARGE_INTEGER): Double;beginResult := x.HighPart * 4.294967296E9 + x.LowPartend;procedure GetCPUUsage;varSysBaseInfo: TSystem_Basic_Information;SysPerfInfo: TSystem_Performance_Information;SysTimeInfo: TSystem_Time_Information;status: Longint; {long}dbSystemTime: Double;dbIdleTime: Double;bLoopAborted : boolean;beginif @NtQuerySystemInformation = nil thenNtQuerySystemInformation := GetProcAddress(GetModuleHandle('ntdll.dll'),'NtQuerySystemInformation');// get number of processors in the systemstatus := NtQuerySystemInformation(SystemBasicInformation, @SysBaseInfo, SizeOf(SysBaseInfo), nil);if status <> 0 then Exit;// Show some informationwith SysBaseInfo dobeginShowMessage(Format('uKeMaximumIncrement: %d'#13'uPageSize: %d'#13+'uMmNumberOfPhysicalPages: %d'+#13+'uMmLowestPhysicalPage: %d'+#13+'uMmHighestPhysicalPage: %d'+#13+'uAllocationGranularity: %d'#13+'uKeActiveProcessors: %d'#13'bKeNumberProcessors: %d',[uKeMaximumIncrement, uPageSize, uMmNumberOfPhysicalPages,uMmLowestPhysicalPage, uMmHighestPhysicalPage, uAllocationGranularity,uKeActiveProcessors, bKeNumberProcessors]));end; bLoopAborted := False;while not bLoopAborted dobegin// get new system timestatus := NtQuerySystemInformation(SystemTimeInformation, @SysTimeInfo, SizeOf(SysTimeInfo), 0);if status <> 0 then Exit;// get new CPU's idle timestatus := NtQuerySystemInformation(SystemPerformanceInformation, @SysPerfInfo, SizeOf(SysPerfInfo), nil);if status <> 0 then Exit;// if it's a first call - skip itif (liOldIdleTime.QuadPart <> 0) thenbegin// CurrentValue = NewValue - OldValuedbIdleTime := Li2Double(SysPerfInfo.liIdleTime) - Li2Double(liOldIdleTime);dbSystemTime := Li2Double(SysTimeInfo.liKeSystemTime) - Li2Double(liOldSystemTime);// CurrentCpuIdle = IdleTime / SystemTimedbIdleTime := dbIdleTime / dbSystemTime;// CurrentCpuUsage% = 100 - (CurrentCpuIdle * 100) / NumberOfProcessorsdbIdleTime := 100.0 - dbIdleTime * 100.0 / SysBaseInfo.bKeNumberProcessors + 0.5;// Show PercentageForm1.Label1.Caption := FormatFloat('CPU Usage: 0.0 %',dbIdleTime);Application.ProcessMessages;// Abort if user pressed ESC or Application is terminatedbLoopAborted := (GetKeyState(VK_ESCAPE) and 128 = 128) or Application.Terminated;end;// store new CPU's idle and system timeliOldIdleTime := SysPerfInfo.liIdleTime;liOldSystemTime := SysTimeInfo.liKeSystemTime;// wait one secondSleep(1000);end;end; procedure TForm1.Button1Click(Sender: TObject);beginGetCPUUsageend; 呵呵下载TeeChartPro7了,有个很强大的Demo程序的看看就直到了,还可以用的 我有一个这方面的东东,网友的做的,如果楼主有兴趣,请帖出EMAIL,我给你发过去。================================================================================ outer2000(天外流星) 能不能给点注释。比如变量的含义,和一些关键的操作 我的E-mail是:[email protected] 或是:[email protected] QQ:89799761 (只有晚上能在线) ADODataset 与 query 怎么将char型转换成int型? 一个初学者的问题。大家路过进来看一下! 哪位大虾有读取计算机硬件基本信息的资料? 数据库模糊查询语句并没有帮我达到目的,帮我啊! 在windows中如何控制右击文件菜单时的显示项? 谁有mastering delphi 7 我用TADOQuery取到一些结果,如何更改某行的某个字段的值? 怎样才能不显示窗体的关闭按扭? 请问DELPHI中有没有这样的控件或是函数?请进里面看一看。谢谢! 急,求救! Delphi中COM服务...
unit Main;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls, TeEngine, Series, ExtCtrls,
TeeProcs, Chart, Buttons;type
TMainForm = class(TForm)
Chart1: TChart;
Button1: TButton;
Series1: TBarSeries;
BitBtn1: TBitBtn;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
MainForm: TMainForm;implementation{$R *.DFM}var
HeapStatus: THeapStatus;procedure TMainForm.Button1Click(Sender: TObject);
begin
HeapStatus := System.GetHeapStatus;
with Series1, HeapStatus do
begin
Add(TotalCommitted, 'Total Committed', clTeeColor);
Add(TotalAllocated, 'Total Allocated', clTeeColor);
Add(TotalFree, 'Total Free', clTeeColor);
Add(FreeSmall, 'Free Small', clTeeColor);
Add(FreeBig, 'Free Big', clTeeColor);
Add(Unused, 'Unused', clTeeColor);
Add(Overhead, 'Overhead', clTeeColor);
end;
end;procedure TMainForm.BitBtn1Click(Sender: TObject);
begin
close;
end;end.
谢谢
下载TeeChartPro7了,有个很强大的Demo程序的看看就直到了,还可以用的
================================================================================
能不能给点注释。
比如变量的含义,和一些关键的操作
或是:[email protected]
QQ:89799761 (只有晚上能在线)