Click here to Skip to main content
Click here to Skip to main content

DynData v1.0 - Win95/98 Performance Counters

, 3 Mar 2000 CPOL
Rate this:
Please Sign up or sign in to vote.
A collection of freeware MFC classes to encapsulate the Windows 95/98 performance counters.

 

Introduction

Welcome to DynData v1.0, a collection of freeware MFC classes to encapsulate the performance counters as stored under the HKEY_DYN_DATA registry key on Windows 95/98.

 

 

Features
History
API Reference
Usage
Contacting the Author

 


Features

  • Simple and clean C++ interface based.
  • The classes are fully Unicode compliant (even though HKEY_DYN_DATA is not available on NT <g>)
  • Full documentation is provided in the form of a HTML file.

The source zip file contains the source code and a simple console based application which exercises the class.


History

V1.0 (31 January 1999)

  • Initial Release.


API Reference

The DynData classes provide the following functions:

CDynDataObject::CDynDataObject
CDynDataObject::EnumCounters
CDynDataEnumerator::EnumObjects
CDynDataCounter::Start
CDynDataCounter::Collect
CDynDataCounter::Stop

 

CDynDataObject::CDynDataObject

 

CDynDataObject::CDynDataObject(LPCTSTR pszObjName, HKEY hObjectKey);
CDynDataObject::CDynDataObject(LPCTSTR pszObjName, LPCTSTR pszComputerName);

Parameters:

  • pszObjName -- This is the name of the performance object e.g. "Dial-Up Adapter" or "Kernel".
  • hObjectKey -- This is the registry key which represents the performance object.
  • pszComputerName -- This is the name of the computer on which to open the performance object. Set this value to NULL to open the object on the local machine.

Remarks:
Constructs a performance object which can be later used for enumeration. The first version of the constructor is used internally by the CDynDataEnumerator class. Normally to enumerate the counters which an object has you would use the second version. Another point to bear in mind is that since the two constructors look pretty much identical, you will need to cast the NULL to a LPCTSTR if you are calling the second constructor yourself.

 

CDynDataObject::EnumCounters

 

BOOL CDynDataObject::EnumCounters(ENUMERATE_DYNDATA_OBJECT_COUNTERS lpEnumFunc, DWORD dwItemData = 0);

Return Value:
TRUE if at least one counter was successfully enumerated for the performance object otherwise FALSE.

Parameters:

  • lpEnumFunc -- The function to be used as the call-back when enumerating the counters which this object has.
  • dwItemData -- This is a DWORD which can be anything you want and will be sent to the call-back function.

Remarks:
The call-back function is of the form:

typedef BOOL (*ENUMERATE_DYNDATA_OBJECT_COUNTERS)(DWORD dwItemData, CDynDataObject& object, const CString& sRegistryName, const CString& sCommonName, const CString& sDescription, BOOL bDifferentiate);

  • dwItemData -- The value as presented in the EnumCounters function.
  • object -- The parameter represents the performance object being enumerated.
  • sRegistryName -- The name of the counter as stored in the registry.
  • sCommonName -- The name of the counter which you would display to an end user.
  • sDescription -- A description of the counter.
  • bDifferentiate -- If TRUE, then the counter represents a rate such as Bytes Received per Second as opposed to an absolute value such as bytes sent.

Returning TRUE from the call-back function will continue the enumeration while returning FALSE will cause the enumeration to stop.

 

CDynDataEnumerator::EnumObjects

 

BOOL CDynDataEnumerator::EnumObjects(ENUMERATE_DYNDATA_OBJECTS lpEnumFunc, DWORD dwItemData = 0, LPCTSTR pszComputerName = NULL);

Return Value:
TRUE if at least one object was successfully enumerated otherwise FALSE.

Parameters:

  • lpEnumFunc -- The function to be used as the call-back when enumerating the performance objects.
  • dwItemData -- This is the value as presented in the EnumObjects() function.
  • pszComputerName -- This is the name of the computer of which to enumerate the performance objects. Set this value to NULL to enumerate the objects on the local machine.

Remarks:
The call-back function is of the form:

typedef BOOL (*ENUMERATE_DYNDATA_OBJECTS)(DWORD dwItemData, CDynDataObject& object);

 

  • dwItemData -- The value as in the EnumObjects function.
  • object -- Represents the current performance object being enumerated.

 

CDynDataCounter::Start

 

BOOL CDynDataCounter::Start(LPCTSTR pszObjName, LPCTSTR pszCounterName, LPCTSTR pszComputerName = NULL);

Return Value:
TRUE if collection of the performance data was started otherwise FALSE.

Parameters:

  • pszObjName -- The name of the performance object e.g. "KERNEL".
  • pszCounterName -- The name of the counter for the performance object e.g. "CPUUsage".
  • pszComputerName -- This is the name of the computer on which the counter is to be collected. Set this value to NULL to start collection on the local machine.

Remarks:
Starts collection of the performance data.

 

CDynDataCounter::Collect

 

BOOL CDynDataCounter::Collect(DWORD& dwData);

Return Value:
TRUE if collection of the performance data was successful otherwise FALSE.

Parameters:

  • dwData -- Upon successful return of the function this will contain the actual value of the performance counter.

Remarks:
Retrieves the current value of the performance counter.

 

CDynDataCounter::Stop

 

BOOL CDynDataCounter::Stop();

Return Value:
TRUE if collection of the performance data was successfully stopped otherwise FALSE.

Remarks:
Stops retrieval of the performance counter.

 


Usage

  • To use the classes in your code, just #include "dyndata.h" in which ever module requires it and also include the dyndata .cpp and .h files in your project.
  • The code is specific to Windows 95/98 and will fail on NT, since NT provides its own kind of performance data using a different retrieval mechanism.


Contacting the Author

PJ Naughter
Email: pjn@indigo..ie
Web: http://www.naughter.com
31 January 1999

 

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

PJ Naughter

United States United States
No Biography provided

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150224.1 | Last Updated 4 Mar 2000
Article Copyright 2000 by PJ Naughter
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid