Counters.Add method

Adds a CounterItem instance to the collection.

Syntax

Counters.Add( _
  ByVal pathname As String _
) As CounterItem

Parameters

pathname [in]

Path to the counter. The path can include a machine name, and must include a performance object name, an object instance name if the specified performance object supports multiple instances, and a counter name. This path specification is not case-sensitive.

For details on specifying a counter path, see Specifying a Counter Path.

Exceptions

Exception type Condition
System.Runtime.InteropServices.COMException You can receive this exception for one of the following reasons:
  • The specified performance object was not found on the computer. The Err.Number value is 0xC0000BB8.
  • The specified counter could not be found. The Err.Number value is 0xC0000BB9.

Remarks

If you specify a wildcard counter in the pathname parameter, the Add method creates one CounterItem object for each expanded path. The Add method then returns a pointer to the first added CounterItem.

If the wildcard would result in a duplicate counter, the error is not reported and no duplicate is created. If an error condition occurs before all counters are created, the error is reported and the remaining counters are not created.

There is no limit to the number of counters that you can add; however, SYSMON will graph only the first 1,024 counters in the collection. There is no limit on the number of counters that SYSMON will display in a report.

To receive notification when a counter is added, implement the OnCounterAdded event.

Requirements

Requirement Value
Minimum supported client
Windows 2000 Professional [desktop apps only]
Minimum supported server
Windows 2000 Server [desktop apps only]
DLL
Sysmon.ocx

See also

CounterItem

Counters

SystemMonitor.BrowseCounters