home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 March / Chip_2002-03_cd1.bin / zkuste / delphi / kompon / d56 / MSYSINFO.ZIP / Demos / GUI / CounterProps.pas < prev    next >
Pascal/Delphi Source File  |  2002-01-04  |  3KB  |  129 lines

  1. unit CounterProps;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   MiTeC_PerfLibNT, MiTeC_PerfLib9x, StdCtrls, ExtCtrls, ComCtrls;
  8.  
  9. type
  10.   TpropCounter = class(TFrame)
  11.     pc: TPageControl;
  12.     tsGeneral: TTabSheet;
  13.     Panel1: TPanel;
  14.     Bevel3: TBevel;
  15.     lType: TLabel;
  16.     lLevel: TLabel;
  17.     lScale: TLabel;
  18.     lSize: TLabel;
  19.     stLevel: TStaticText;
  20.     stName: TEdit;
  21.     stType: TStaticText;
  22.     stScale: TStaticText;
  23.     stSize: TStaticText;
  24.     lName: TLabel;
  25.     Memo: TMemo;
  26.     Label1: TLabel;
  27.     Bevel1: TBevel;
  28.     tsObject: TTabSheet;
  29.     Bevel2: TBevel;
  30.     lCntr: TLabel;
  31.     lLevel1: TLabel;
  32.     lInst: TLabel;
  33.     lPage: TLabel;
  34.     stLevel1: TStaticText;
  35.     stObjName: TStaticText;
  36.     stCntr: TStaticText;
  37.     stInst: TStaticText;
  38.     stPage: TStaticText;
  39.     lObjname: TLabel;
  40.     Memo1: TMemo;
  41.     Label7: TLabel;
  42.     Bevel4: TBevel;
  43.     lCtrs: TLabel;
  44.     stCtrs: TStaticText;
  45.     Bevel5: TBevel;
  46.     Bevel6: TBevel;
  47.     lTime: TLabel;
  48.     stTime: TStaticText;
  49.     lFreq: TLabel;
  50.     stFreq: TStaticText;
  51.   private
  52.     FCounter: TObject;
  53.     FPerfLib9x: TPerfLib9x;
  54.   public
  55.     property Counter: TObject read FCounter write FCounter;
  56.     property PerfLib9x: TPerfLib9x read FPerfLib9x write FPerfLib9x;
  57.     procedure Refresh;
  58.   end;
  59.  
  60. implementation
  61.  
  62. uses MiTeC_Routines;
  63.  
  64. {$R *.DFM}
  65.  
  66. { TpropCounter }
  67.  
  68. procedure TpropCounter.Refresh;
  69. var
  70.   po: TPerfObject;
  71.   sc,so: string;
  72.   i: integer;
  73. begin
  74.   if IsNT then begin
  75.     if Counter is TPerfCounter then begin
  76.       pc.ActivePage:=tsGeneral;
  77.       po:=TPerfCounter(Counter).ParentObject;
  78.     end else begin
  79.       pc.ActivePage:=tsObject;
  80.       tsGeneral.TabVisible:=False;
  81.       po:=TPerfObject(Counter);
  82.     end;
  83.     if Counter is TPerfCounter then
  84.       with TPerfCounter(Counter) do begin
  85.         stName.Text:=Name;
  86.         stType.Caption:=GetCounterTypeStr(CounterType);
  87.         stScale.Caption:=Format('%d',[DefaultScale]);
  88.         stSize.Caption:=Format('%d',[CounterSize]);
  89.         stLevel.Caption:=GetDetailLevelStr(DetailLevel);
  90.         Memo.Text:=Description;
  91.       end;
  92.     with po do begin
  93.       stObjName.Caption:=Name;
  94.       stCntr.Caption:=Format('%d',[DefaultCounter]);
  95.       stPage.Caption:=Format('%d',[CodePage]);
  96.       stLevel1.Caption:=GetDetailLevelStr(DetailLevel);
  97.       if InstanceCount>-1 then
  98.         stInst.Caption:=Format('%d',[InstanceCount])
  99.       else
  100.         stInst.Caption:='0';
  101.       stCtrs.Caption:=Format('%d',[CounterCount]);
  102.       stTime.Caption:=FormatSeconds(PerfTime.QuadPart div timer100n,True,False,True);
  103.       stFreq.Caption:=FormatFloat('#,#0',PerfFreq.QuadPart);
  104.       Memo1.Text:=Description;
  105.     end;
  106.   end else begin
  107.     sc:=StrPas(PChar(Counter));
  108.     i:=Pos('\',sc);
  109.     if i>0 then begin
  110.       pc.ActivePage:=tsGeneral;
  111.       so:=Copy(sc,1,i-1);
  112.     end else begin
  113.       pc.ActivePage:=tsObject;
  114.       tsGeneral.TabVisible:=False;
  115.       so:=sc;
  116.     end;
  117.     with PerfLib9x do begin
  118.       if i>0 then begin
  119.         stName.Text:=SysDataName[sc];
  120.         Memo.Text:=SysDataDesc[sc];
  121.       end;
  122.       stObjName.Caption:=SysDataName[so];
  123.       Memo1.Text:=SysDataDesc[so];
  124.     end;
  125.   end;
  126. end;
  127.  
  128. end.
  129.