PdhExpandWildCardPathA 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.
To use handles to data sources, use the PdhExpandWildCardPathH function.
PDH_FUNCTION PdhExpandWildCardPathA(
[in] LPCSTR szDataSource,
[in] LPCSTR szWildCardPath,
[out] PZZSTR mszExpandedPathList,
[in, out] LPDWORD pcchPathListLength,
[in] DWORD dwFlags
);
[in] szDataSource
Null-terminated string that contains the name of a log file. The function uses the performance objects and counters defined in the log file to expand the path specified in the szWildCardPath parameter.
If NULL, the function searches the computer specified in szWildCardPath.
[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 the szDataSource parameter is NULL, 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.
[in] dwFlags
Flags that indicate which wildcard characters not to expand. You can specify one or more flags.
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 |
---|---|
|
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. |
|
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. |
|
The specified object does not contain an instance. |
|
Unable to allocate memory to support this function. |
|
Unable to find the specified object on the computer or in the log file. |
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.
PdhExpandWildCardPath differs from PdhExpandCounterPath in the following ways:
- Lets you control which wildcard characters are expanded.
- The contents of a log file can be used as the source of counter names.
\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
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 the object does not contain an instance, an error occurs.
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 PdhExpandWildCardPath 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.
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 |