PdhExpandWildCardPathHW function (pdh.h)

Examines the specified computer or log file and returns those counter paths that match the given counter path which contains wildcard characters.

This function is identical to the PdhExpandWildCardPath function, except that it supports the use of handles to data sources.

Syntax

PDH_FUNCTION PdhExpandWildCardPathHW(
  [in]      PDH_HLOG hDataSource,
  [in]      LPCWSTR  szWildCardPath,
  [out]     PZZWSTR  mszExpandedPathList,
  [in, out] LPDWORD  pcchPathListLength,
  [in]      DWORD    dwFlags
);

Parameters

[in] hDataSource

Handle to a data source returned by the PdhBindInputDataSource function.

[in] szWildCardPath

Null-terminated string that specifies the counter path to expand. The maximum length of a counter path is PDH_MAX_COUNTER_PATH.

If hDataSource is a real time data source, the function searches the computer specified in the path for matches. If the path does not specify a computer, the function searches the local computer.

[out] mszExpandedPathList

Caller-allocated buffer that receives a list of null-terminated counter paths that match the wildcard specification in the szWildCardPath. The list is terminated by two NULL characters. Set to NULL if pcchPathListLength is zero.

[in, out] pcchPathListLength

Size of the mszExpandedPathList buffer, in TCHARs. If zero on input and the object exists, the function returns PDH_MORE_DATA and sets this parameter to the required buffer size. If the buffer is larger than the required size, the function sets this parameter to the actual size of the buffer that was used. If the specified size on input is greater than zero but less than the required size, you should not rely on the returned size to reallocate the buffer.

Note  You must add one to the required size on Windows XP.
 

[in] dwFlags

Flags that indicate which wildcard characters not to expand. You can specify one or more flags.

Value Meaning
PDH_NOEXPANDCOUNTERS
Do not expand the counter name if the path contains a wildcard character for counter name.
PDH_NOEXPANDINSTANCES
Do not expand the instance name if the path contains a wildcard character for parent instance, instance name, or instance index.
PDH_REFRESHCOUNTERS
Refresh the counter list.

Return value

If the function succeeds, it returns ERROR_SUCCESS.

If the function fails, the return value is a system error code or a PDH error code.

Return code Description
PDH_MORE_DATA
The mszExpandedPathList buffer is not large enough to contain the list of paths. This return value is expected if pcchPathListLength is zero on input. If the specified size on input is greater than zero but less than the required size, you should not rely on the returned size to reallocate the buffer.
PDH_INVALID_ARGUMENT
A parameter is not valid. For example, on some releases you could receive this error if the specified size on input is greater than zero but less than the required size.
PDH_MEMORY_ALLOCATION_FAILURE
Unable to allocate memory to support this function.
PDH_CSTATUS_NO_OBJECT
Unable to find the specified object on the computer or in the log file.

Remarks

You should call this function twice, the first time to get the required buffer size (set mszExpandedPathList to NULL and pcchPathListLength to 0), and the second time to get the data.

PdhExpandWildCardPathH differs from PdhExpandCounterPath in the following ways:

  1. Lets you control which wildcard characters are expanded.
  2. The contents of a log file can be used as the source of counter names.
The general counter path format is as follows:

\computer\object(parent/instance#index)\counter

The parent, instance, index, and counter components of the counter path may contain either a valid name or a wildcard character. The computer, parent, instance, and index components are not necessary for all counters.

The following is a list of the possible formats:

  • \\computer\object(parent/instance#index)\counter
  • \\computer\object(parent/instance)\counter
  • \\computer\object(instance#index)\counter
  • \\computer\object(instance)\counter
  • \\computer\object\counter
  • \object(parent/instance#index)\counter
  • \object(parent/instance)\counter
  • \object(instance#index)\counter
  • \object(instance)\counter
  • \object\counter
Use an asterisk (*) as the wildcard character, for example, \object(*)\counter.

If a wildcard character is specified in the parent name, all instances of the specified object that match the specified instance and counter fields will be returned. For example, \object(*/instance)\counter.

If a wildcard character is specified in the instance name, all instances of the specified object and parent object will be returned if all instance names corresponding to the specified index match the wildcard character. For example, \object(parent/*)\counter.

If a wildcard character is specified in the counter name, all counters of the specified object are returned.

Partial counter path string matches (for example, "pro*") are supported.

Prior to Windows Vista:  Partial wildcard matches are not supported.

Note

The pdh.h header defines PdhExpandWildCardPathH as an alias that automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that is not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.

Requirements

Requirement Value
Minimum supported client Windows XP [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Target Platform Windows
Header pdh.h
Library Pdh.lib
DLL Pdh.dll

See also

PdhBindInputDataSourceA function

PdhEnumObjectItemsHA function

PdhEnumObjectsHA function

PdhExpandWildCardPathW function