如何监测cpu和内存的使用情况(代码),急(100)相送,象任务管理器中的那样曲线,
曲线可以用paintbox画出来,数据怎么样取回????
尽快揭帖

解决方案 »

  1.   

    得到是用API,GETSYSTEMINFO,至于画线就自己画好了,数据得到了,那个还不好办?加个TIMER
      

  2.   

    CSDN  怎么啦?我想给你发个程序也发不出去不好意思
      

  3.   

    用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);
    begin
    close;
    end;end.
      

  4.   

    lihao_ningxia(耗子)  这个程序我没有作过,请不吝给点代码
    谢谢
      

  5.   

    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;
      

  6.   

    呵呵
    下载TeeChartPro7了,有个很强大的Demo程序的看看就直到了,还可以用的
      

  7.   

    我有一个这方面的东东,网友的做的,如果楼主有兴趣,请帖出EMAIL,我给你发过去。
    ================================================================================
      

  8.   

    outer2000(天外流星)    
    能不能给点注释。
    比如变量的含义,和一些关键的操作
      

  9.   

    我的E-mail是:[email protected]
            或是:[email protected]
              QQ:89799761   (只有晚上能在线)