CPdh
Features
History V1.0 (9 February 1999)
V1.01 (5 September 1999)
pjPdhState::pjPdhState()
V1.02 (13 September 1999)
V1.03 (25 January 2000)
API Reference The CPdh classes provide the following functions:
CPdhException::CPdhException CPdhException::m_Status CPdhException::GetErrorMessage CPdhCounterInfo CPdhCounter::CPdhCounter CPdhCounter::GetRawValue CPdhCounter::SplitPath CPdhCounter::GetInfo CPdhCounter::CalculateFromRawValue CPdhCounter::GetFormattedValue CPdhCounter::ComputeStatistics CPdhCounter::SetScaleFactor CPdhQuery::Open CPdhQuery::Close CPdhQuery::Add CPdhQuery::Remove CPdhQuery::Collect CPdh::ValidatePath CPdh::ExpandPath CPdh::ConnectMachine CPdh::EnumMachines CPdh::EnumObjects CPdh::EnumObjectItems CPdh::GetDefaultCounter CPdh::GetDefaultObject CPdh::BrowseCounters CPdh::ParseInstanceName CPdh::ThrowPdhException
Parameters:
Remarks: This member function is called when a CPdhException object is created. To throw a CPdhException, call the function CPdh::ThrowPdhException().
CPdhException
Return Value: Nonzero if the function is successful; otherwise 0 if no error message text is available.
Remarks: Call this member function to provide text about an error that has occurred. Note: GetErrorMessage() will not copy more than nMaxError-1 characters to the buffer, and it will always add a trailing null to end the string. If the buffer is too small, the error message may be truncated.
GetErrorMessage()
nMaxError-1
Member Variables:
Remarks: Constructs a PDH counter using the specified name. The counter does not become valid until it has been added to a query using CPdhQuery::Add(). If any error occurs, CPdhCounter throws a CPdh::ThrowPdhException().
CPdhQuery::Add()
CPdhCounter
Return Value: The counter type. The possible counter types are described in winperf.h.
Remarks: Returns the current raw value of the counter. If any error occurs, GetRawValue() throws a CPdh::ThrowPdhException().
GetRawValue()
CPdh::ThrowPdhException()
Remarks: Parses the elements of the counter path and stores the results in the parameters passed by the caller. If any error occurs, GetRawValue() throws a CPdh::ThrowPdhException.
Remarks: Retrieves information about a counter, such as data size, counter type, path, and user-supplied data values. If any error occurs, GetInfo() throws a CPdh::ThrowPdhException.
GetInfo()
The value selected from the previous table can be combined using the OR operator with one of the following scaling flags:
Remarks: Computes the current value of the counter, using the raw counter data passed in the parameter list. If any error occurs, CalculateFromRawValue() throws a CPdh::ThrowPdhException.
CalculateFromRawValue()
Remarks: Returns the current value of the counter in the format requested by the caller. If any error occurs, GetFormattedValue() throws a CPdh::ThrowPdhException.
GetFormattedValue()
dwFirstEntry-1
PDH_RAW_COUNTER
PDH_STATISTICS
Remarks: Computes statistics for a counter from an array of raw values. If any error occurs, ComputeStatistics() throws a CPdh::ThrowPdhException.
ComputeStatistics()
Remarks: Sets the scale factor that is applied to the calculated value of the counter when you request the formatted counter value. If the PDH_FMT_NOSCALE flag is set, then this scale factor is ignored. If any error occurs, SetScaleFactor throws a CPdh::ThrowPdhException.
Remarks: Creates and initialises a unique query structure that is used to manage collection of performance data. If any error occurs, Open() throws a CPdh::ThrowPdhException.
Open()
Remarks: Closes all counters contained in the query, closes all handles related to the query, and frees all memory associated with the query. If any error occurs, Close() throws a CPdh::ThrowPdhException.
Close()
Remarks: Initialises a counter structure for the specified counter in the query. If any error occurs, Add() throws a CPdh::ThrowPdhException.
Add()
Remarks: Removes a counter from a query. If any error occurs, Remove() throws a CPdh::ThrowPdhException.
Remove()
Remarks: Collects the current raw data value for all counters in this query and updates the status code of each counter. If any error occurs, Collect() throws a CPdh::ThrowPdhException.
Collect()
Remarks: Validates that the specified counter is present on the machine specified in the counter path. If any error occurs, ValidatePath() throws a CPdh::ThrowPdhException.
ValidatePath()
Remarks: Examines the specified machine (or local machine if none is specified) for counters and instances of counters that match the wild card strings in the counter path. The counter path format is assumed to be:
\\machine\object(parent/instance#index)\countername
and the parent, instance, index, and countername elements may contain either a valid name or a wild card character. If any error occurs, ExpandPath() throws a CPdh::ThrowPdhException.
ExpandPath()
Remarks: Connects to the specified machine, and creates and initialises a machine entry in the PDH DLL. If any error occurs, ConnectMachine() throws a CPdh::ThrowPdhException.
ConnectMachine()
Remarks: Returns a list of the names of the machines that have been opened previously by the PDH DLL. If any error occurs, EnumMachines() throws a CPdh::ThrowPdhException.
EnumMachines()
Remarks: Returns a list of objects available on the specified machine. If any error occurs, EnumObjects() throws a CPdh::ThrowPdhException.
EnumObjects()
Remarks: Returns the available counters and instances provided by the specified object on the specified machine. If any error occurs, EnumObjectItems() throws a CPdh::ThrowPdhException.
EnumObjectItems()
Remarks: Retrieves the name of the default counter for the specified object. This can be used to set the initial selection of the counter browser list/combo box. If any error occurs, GetDefaultCounter() throws a CPdh::ThrowPdhException.
GetDefaultCounter()
Remarks: Retrieves the name of the default performance object. The name can be used to select the default entry in the object browser list box. If any error occurs, GetDefaultObject() throws a CPdh::ThrowPdhException.
GetDefaultObject()
Remarks: Displays the counter browsing dialog box so that the user can select the counters to be returned to the caller. If any error occurs, BrowseCounters() throws a CPdh::ThrowPdhException.
BrowseCounters()
instance instance#index parent/instance parent/instance#index
Remarks: Parses the elements of an instance string and returns them in the buffers supplied by the caller. If any error occurs, ParseInstanceName() throws a CPdh::ThrowPdhException.
ParseInstanceName()
Remarks: Throws an PDH exception.
Usage:
#include cpdh.h
GetVersionEx()
Contacting the Author PJ Naughter Email: pjn@indigo..ie Web: http://www.naughter.com 25 January 2000
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
General News Suggestion Question Bug Answer Joke Rant Admin
Skills that self-taught computer programmers lack