Skip to content

Latest commit

 

History

History
196 lines (153 loc) · 6.07 KB

nf-pdh-pdhgetdefaultperfcounterw.md

File metadata and controls

196 lines (153 loc) · 6.07 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:pdh.PdhGetDefaultPerfCounterW
PdhGetDefaultPerfCounterW function (pdh.h)
Retrieves the name of the default counter for the specified object. This name can be used to set the initial counter selection in the Browse Counter dialog box. To use handles to data sources, use the PdhGetDefaultPerfCounterH function. (Unicode)
PdhGetDefaultPerfCounter
PdhGetDefaultPerfCounter function [Perf]
PdhGetDefaultPerfCounterW
_win32_pdhgetdefaultperfcounter
base.pdhgetdefaultperfcounter
pdh/PdhGetDefaultPerfCounter
pdh/PdhGetDefaultPerfCounterW
perf.pdhgetdefaultperfcounter
perf\pdhgetdefaultperfcounter.htm
perf
0eb78071-3496-40e9-91b0-3c06547c88d5
12/05/2018
PdhGetDefaultPerfCounter, PdhGetDefaultPerfCounter function [Perf], PdhGetDefaultPerfCounterA, PdhGetDefaultPerfCounterW, _win32_pdhgetdefaultperfcounter, base.pdhgetdefaultperfcounter, pdh/PdhGetDefaultPerfCounter, pdh/PdhGetDefaultPerfCounterA, pdh/PdhGetDefaultPerfCounterW, perf.pdhgetdefaultperfcounter
pdh.h
Windows
Windows XP [desktop apps only]
Windows Server 2003 [desktop apps only]
PdhGetDefaultPerfCounterW (Unicode) and PdhGetDefaultPerfCounterA (ANSI)
Pdh.lib
Pdh.dll
Windows
19H1
PdhGetDefaultPerfCounterW
pdh/PdhGetDefaultPerfCounterW
c++
APIRef
kbSyntax
DllExport
Pdh.dll
PdhGetDefaultPerfCounter
PdhGetDefaultPerfCounterA
PdhGetDefaultPerfCounterW

PdhGetDefaultPerfCounterW function

-description

Retrieves the name of the default counter for the specified object. This name can be used to set the initial counter selection in the Browse Counter dialog box.

To use handles to data sources, use the PdhGetDefaultPerfCounterH function.

-parameters

-param szDataSource [in]

Should be NULL.

If you specify a log file, szDefaultCounterName will be a null string.

-param szMachineName [in]

Null-terminated string that specifies the name of the computer used to verify the object name. If NULL, the local computer is used to verify the object name.

-param szObjectName [in]

Null-terminated string that specifies the name of the object whose default counter name you want to retrieve.

-param szDefaultCounterName [out]

Caller-allocated buffer that receives the null-terminated default counter name. Set to NULL if pcchBufferSize is zero.

-param pcchBufferSize [in, out]

Size of the szDefaultCounterName buffer, in TCHARs. If zero on input, 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.

-returns

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. The following are possible values.

Return code Description
PDH_MORE_DATA
The szDefaultCounterName buffer is too small to contain the counter name. This return value is expected if pcchBufferSize 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 required 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 in order to complete the function.
PDH_CSTATUS_NO_MACHINE
The specified computer is offline or unavailable.
PDH_CSTATUS_NO_COUNTERNAME
The default counter name cannot be read or found.
PDH_CSTATUS_NO_OBJECT
The specified object could not be found.
PDH_CSTATUS_NO_COUNTER
The object did not specify a default counter.

-remarks

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

Note

The pdh.h header defines PdhGetDefaultPerfCounter as an alias which 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 not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.

-see-also

PdhGetDefaultPerfCounterH

PdhGetDefaultPerfObject