📄 jwawinperf.pas
字号:
{******************************************************************************}
{ }
{ Performance Monitoring API interface Unit for Object Pascal }
{ }
{ Portions created by Microsoft are Copyright (C) 1995-2001 Microsoft }
{ Corporation. All Rights Reserved. }
{ }
{ The original file is: winperf.h, released June 2000. The original Pascal }
{ code is: WinPerf.pas, released December 2000. The initial developer of the }
{ Pascal code is Marcel van Brakel (brakelm@chello.nl). }
{ }
{ Portions created by Marcel van Brakel are Copyright (C) 1999-2001 }
{ Marcel van Brakel. All Rights Reserved. }
{ }
{ Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI) }
{ }
{ You may retrieve the latest version of this file at the Project JEDI home }
{ page, located at http://delphi-jedi.org or my personal homepage located at }
{ http://members.chello.nl/m.vanbrakel2 }
{ }
{ The contents of this file are used with permission, subject to the Mozilla }
{ Public License Version 1.1 (the "License"); you may not use this file except }
{ in compliance with the License. You may obtain a copy of the License at }
{ http://www.mozilla.org/MPL/MPL-1.1.html }
{ }
{ Software distributed under the License is distributed on an "AS IS" basis, }
{ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
{ the specific language governing rights and limitations under the License. }
{ }
{ Alternatively, the contents of this file may be used under the terms of the }
{ GNU Lesser General Public License (the "LGPL License"), in which case the }
{ provisions of the LGPL License are applicable instead of those above. }
{ If you wish to allow use of your version of this file only under the terms }
{ of the LGPL License and not to allow others to use your version of this file }
{ under the MPL, indicate your decision by deleting the provisions above and }
{ replace them with the notice and other provisions required by the LGPL }
{ License. If you do not delete the provisions above, a recipient may use }
{ your version of this file under either the MPL or the LGPL License. }
{ }
{ For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
{ }
{******************************************************************************}
unit JwaWinPerf;
{$WEAKPACKAGEUNIT}
{$HPPEMIT ''}
{$HPPEMIT '#include "WinPerf.h"'}
{$HPPEMIT ''}
{$I WINDEFINES.INC}
interface
uses
JwaWinBase, JwaWinType;
// Header file for the Performance Monitor data.
//
// This file contains the definitions of the data structures returned
// by the Configuration Registry in response to a request for
// performance data. This file is used by both the Configuration
// Registry and the Performance Monitor to define their interface.
// The complete interface is described here, except for the name
// of the node to query in the registry. It is
//
// HKEY_PERFORMANCE_DATA.
//
// By querying that node with a subkey of "Global" the caller will
// retrieve the structures described here.
//
// There is no need to RegOpenKey() the reserved handle HKEY_PERFORMANCE_DATA,
// but the caller should RegCloseKey() the handle so that network transports
// and drivers can be removed or installed (which cannot happen while
// they are open for monitoring.) Remote requests must first
// RegConnectRegistry().
// Data structure definitions.
// In order for data to be returned through the Configuration Registry
// in a system-independent fashion, it must be self-describing.
// In the following, all offsets are in bytes.
//
// Data is returned through the Configuration Registry in a
// a data block which begins with a _PERF_DATA_BLOCK structure.
//
const
PERF_DATA_VERSION = 1;
{$EXTERNALSYM PERF_DATA_VERSION}
PERF_DATA_REVISION = 1;
{$EXTERNALSYM PERF_DATA_REVISION}
type
PPERF_DATA_BLOCK = ^PERF_DATA_BLOCK;
{$EXTERNALSYM PPERF_DATA_BLOCK}
_PERF_DATA_BLOCK = record
Signature: array [0..3] of WCHAR; // Signature: Unicode "PERF"
LittleEndian: DWORD; // 0 = Big Endian, 1 = Little Endian
Version: DWORD; // Version of these data structures
// starting at 1
Revision: DWORD; // Revision of these data structures
// starting at 0 for each Version
TotalByteLength: DWORD; // Total length of data block
HeaderLength: DWORD; // Length of this structure
NumObjectTypes: DWORD; // Number of types of objects
// being reported
DefaultObject: LONG; // Object Title Index of default
// object to display when data from
// this system is retrieved (-1 =
// none, but this is not expected to
// be used)
SystemTime: SYSTEMTIME; // Time at the system under
// measurement
PerfTime: LARGE_INTEGER; // Performance counter value
// at the system under measurement
PerfFreq: LARGE_INTEGER; // Performance counter frequency
// at the system under measurement
PerfTime100nSec: LARGE_INTEGER; // Performance counter time in 100 nsec
// units at the system under measurement
SystemNameLength: DWORD; // Length of the system name
SystemNameOffset: DWORD; // Offset, from beginning of this
// structure, to name of system
// being measured
end;
{$EXTERNALSYM _PERF_DATA_BLOCK}
PERF_DATA_BLOCK = _PERF_DATA_BLOCK;
{$EXTERNALSYM PERF_DATA_BLOCK}
TPerfDataBlock = PERF_DATA_BLOCK;
PPerfDataBlock = PPERF_DATA_BLOCK;
//
// The _PERF_DATA_BLOCK structure is followed by NumObjectTypes of
// data sections, one for each type of object measured. Each object
// type section begins with a _PERF_OBJECT_TYPE structure.
//
PPERF_OBJECT_TYPE = ^PERF_OBJECT_TYPE;
{$EXTERNALSYM PPERF_OBJECT_TYPE}
_PERF_OBJECT_TYPE = record
TotalByteLength: DWORD; // Length of this object definition
// including this structure, the
// counter definitions, and the
// instance definitions and the
// counter blocks for each instance:
// This is the offset from this
// structure to the next object, if
// any
DefinitionLength: DWORD; // Length of object definition,
// which includes this structure
// and the counter definition
// structures for this object: this
// is the offset of the first
// instance or of the counters
// for this object if there is
// no instance
HeaderLength: DWORD; // Length of this structure: this
// is the offset to the first
// counter definition for this
// object
ObjectNameTitleIndex: DWORD; // Index to name in Title Database
ObjectNameTitle: LPWSTR; // Initially NULL, for use by
// analysis program to point to
// retrieved title string
ObjectHelpTitleIndex: DWORD; // Index to Help in Title Database
ObjectHelpTitle: LPWSTR; // Initially NULL, for use by
// analysis program to point to
// retrieved title string
DetailLevel: DWORD; // Object level of detail (for
// controlling display complexity);
// will be min of detail levels
// for all this object's counters
NumCounters: DWORD; // Number of counters in each
// counter block (one counter
// block per instance)
DefaultCounter: LONG; // Default counter to display when
// this object is selected, index
// starting at 0 (-1 = none, but
// this is not expected to be used)
NumInstances: LONG; // Number of object instances
// for which counters are being
// returned from the system under
// measurement. If the object defined
// will never have any instance data
// structures (PERF_INSTANCE_DEFINITION)
// then this value should be -1, if the
// object can have 0 or more instances,
// but has none present, then this
// should be 0, otherwise this field
// contains the number of instances of
// this counter.
CodePage: DWORD; // 0 if instance strings are in
// UNICODE, else the Code Page of
// the instance names
PerfTime: LARGE_INTEGER; // Sample Time in "Object" units
PerfFreq: LARGE_INTEGER; // Frequency of "Object" units in
// counts per second.
end;
{$EXTERNALSYM _PERF_OBJECT_TYPE}
PERF_OBJECT_TYPE = _PERF_OBJECT_TYPE;
{$EXTERNALSYM PERF_OBJECT_TYPE}
TPerfObjectType = PERF_OBJECT_TYPE;
PPerfObjectType = PPERF_OBJECT_TYPE;
const
PERF_NO_INSTANCES = -1; // no instances (see NumInstances above)
{$EXTERNALSYM PERF_NO_INSTANCES}
//
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//
// PERF_COUNTER_DEFINITION.CounterType field values
//
//
// Counter ID Field Definition:
//
// 3 2 2 2 2 1 1 1
// 1 8 4 2 0 6 2 0 8 0
// +--------+--------+----+----+--------+--------+----+----+----------------+
// |Display |Calculation |Time|Counter | |Ctr |Size| |
// |Flags |Modifiers |Base|SubType |Reserved|Type|Fld | Reserved |
// +--------+--------+----+----+--------+--------+----+----+----------------+
//
//
// The counter type is the "or" of the following values as described below
//
// select one of the following to indicate the counter's data size
//
PERF_SIZE_DWORD = $00000000;
{$EXTERNALSYM PERF_SIZE_DWORD}
PERF_SIZE_LARGE = $00000100;
{$EXTERNALSYM PERF_SIZE_LARGE}
PERF_SIZE_ZERO = $00000200; // for Zero Length Fields
{$EXTERNALSYM PERF_SIZE_ZERO}
PERF_SIZE_VARIABLE_LEN = $00000300; // length is in CounterLength Fields
// of Counter Definition struct
{$EXTERNALSYM PERF_SIZE_VARIABLE_LEN}
//
// select one of the following values to indicate the counter field usage
//
PERF_TYPE_NUMBER = $00000000; // a number (not a counter)
{$EXTERNALSYM PERF_TYPE_NUMBER}
PERF_TYPE_COUNTER = $00000400; // an increasing numeric Value
{$EXTERNALSYM PERF_TYPE_COUNTER}
PERF_TYPE_TEXT = $00000800; // a text Fields
{$EXTERNALSYM PERF_TYPE_TEXT}
PERF_TYPE_ZERO = $00000C00; // displays a zero
{$EXTERNALSYM PERF_TYPE_ZERO}
//
// If the PERF_TYPE_NUMBER field was selected, then select one of the
// following to describe the Number
//
PERF_NUMBER_HEX = $00000000; // display as HEX Value
{$EXTERNALSYM PERF_NUMBER_HEX}
PERF_NUMBER_DECIMAL = $00010000; // display as a decimal integer
{$EXTERNALSYM PERF_NUMBER_DECIMAL}
PERF_NUMBER_DEC_1000 = $00020000; // display as a decimal/1000
{$EXTERNALSYM PERF_NUMBER_DEC_1000}
//
// If the PERF_TYPE_COUNTER value was selected then select one of the
// following to indicate the type of counter
//
PERF_COUNTER_VALUE = $00000000; // display counter Value
{$EXTERNALSYM PERF_COUNTER_VALUE}
PERF_COUNTER_RATE = $00010000; // divide ctr / delta time
{$EXTERNALSYM PERF_COUNTER_RATE}
PERF_COUNTER_FRACTION = $00020000; // divide ctr / base
{$EXTERNALSYM PERF_COUNTER_FRACTION}
PERF_COUNTER_BASE = $00030000; // base value used in fractions
{$EXTERNALSYM PERF_COUNTER_BASE}
PERF_COUNTER_ELAPSED = $00040000; // subtract counter from current time
{$EXTERNALSYM PERF_COUNTER_ELAPSED}
PERF_COUNTER_QUEUELEN = $00050000; // Use Queuelen processing func.
{$EXTERNALSYM PERF_COUNTER_QUEUELEN}
PERF_COUNTER_HISTOGRAM = $00060000; // Counter begins or ends a histogram
{$EXTERNALSYM PERF_COUNTER_HISTOGRAM}
PERF_COUNTER_PRECISION = $00070000; // divide ctr / private clock
{$EXTERNALSYM PERF_COUNTER_PRECISION}
//
// If the PERF_TYPE_TEXT value was selected, then select one of the
// following to indicate the type of TEXT data.
//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -