PdhParseInstanceName
The PdhParseInstanceName function parses the elements of an instance string and returns them in the buffers supplied by the caller.
PDH_STATUS PdhParseInstanceName(
LPCTSTR szInstanceString,
LPTSTR szInstanceName,
LPDWORD pcchInstanceNameLength,
LPTSTR szParentName,
LPDWORD pcchParentNameLength,
LPDWORD lpIndex
);
Parameters
- szInstanceString
- [in] A pointer to a null-terminated string containing the instance substring to parse into individual components. This string can contain the following formats, and is less than MAX_PATH characters in length:
instance
instance#index
parent/instance
parent/instance#index
- szInstanceName
- [out] A pointer to a null-terminated string containing the name of the buffer that receives the instance name parsed from the instance string. This pointer can be NULL if the variable referenced by the pcchInstanceNameLength parameter is zero.
- pcchInstanceNameLength
- [in] A pointer to a DWORD that contains the length of the szInstanceName buffer. If the value of this variable is zero, the buffer size required to hold the instance name will be returned.
- szParentName
- [out] A pointer to a null-terminated string containing the name of a buffer that receives the name of the parent index if one is specified. This parameter can be NULL if the value of the variable referenced by the pcchParentNameLength parameter is zero.
- pcchParentNameLength
- [in/out] A pointer to a DWORD that contains the length of the szParentName buffer. If the value of this variable is zero, the buffer size required to hold the instance name is returned.
- lpIndex
- [out] A pointer to a DWORD that receives the index value of the instance. If an index entry is not present in the string, then this value is zero. This parameter can be NULL.
Return Values
If the function succeeds, it returns ERROR_SUCCESS.
If the function fails, the return value is a PDH error status defined in PDHMsg.h. The following are possible error values.
Error value |
Description |
PDH_INVALID_ARGUMENT |
An argument is invalid or incorrect. |
PDH_INSUFFICIENT_BUFFER |
One or both of the string buffers supplied is not large enough for the strings to be returned. |
PDH_INVALID_INSTANCE |
The instance string is incorrectly formatted, exceeds MAX_PATH characters in length, or cannot be parsed. |
Windows NT/2000: Requires Windows NT 4.0 or later.
Header: Declared in Pdh.h.
Library: Use Pdh.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000.
See Also
PdhMakeCounterPath