Performance Data Helper Error Codes

All Performance Data Helper (PDH) functions return a value of type PDH_STATUS. If the function succeeds, the return value is ERROR_SUCCESS. Otherwise, the function returns a system error code or a PDH error code. To retrieve the description text for the error in your application, use the FormatMessage function as shown in the following example.

#include <windows.h>
#include <stdio.h>
#include <pdhmsg.h>

void main(void)
{
    HANDLE hPdhLibrary = NULL;
    LPWSTR pMessage = NULL;
    DWORD dwErrorCode = PDH_PLA_ERROR_ALREADY_EXISTS;

    hPdhLibrary = LoadLibrary(L"pdh.dll");
    if (NULL == hPdhLibrary)
    {
        wprintf(L"LoadLibrary failed with %lu\n", GetLastError());
        return;
    }

    if (!FormatMessage(FORMAT_MESSAGE_FROM_HMODULE |
                       FORMAT_MESSAGE_ALLOCATE_BUFFER |
                       FORMAT_MESSAGE_IGNORE_INSERTS,
                       hPdhLibrary,
                       dwErrorCode,
                       0,
                       (LPWSTR)&pMessage,
                       0,
                       NULL))
    {
        wprintf(L"Format message failed with 0x%x\n", GetLastError());
        return;
    }

    wprintf(L"Formatted message: %ls\n", pMessage);
    LocalFree(pMessage);
}

For data collection and formatting functions, it is important to remember that the return value of the function indicates the success or error of the function call and not necessarily that of the counter data. Always check the CStatus member of the counter value returned to ensure that the data returned is valid before you use it. If the value of the CStatus member does not indicate success, do not use the data.

The following table provides a list of error codes that are specific to PDH. These values are defined in the pdhmsg.h header file.

SymbolicCodeDescription
PDH_CSTATUS_VALID_DATA0x00000000The returned data is valid.
PDH_CSTATUS_NEW_DATA0x00000001The return data value is valid and different from the last sample.
PDH_CSTATUS_NO_MACHINE0x800007D0Unable to connect to the specified computer, or the computer is offline.
PDH_CSTATUS_NO_INSTANCE0x800007D1The specified instance is not present.
PDH_MORE_DATA0x800007D2There is more data to return than would fit in the supplied buffer. Allocate a larger buffer and call the function again.
PDH_CSTATUS_ITEM_NOT_VALIDATED0x800007D3The data item has been added to the query but has not been validated nor accessed. No other status information on this data item is available.
PDH_RETRY0x800007D4The selected operation should be retried.
PDH_NO_DATA0x800007D5No data to return.
PDH_CALC_NEGATIVE_DENOMINATOR0x800007D6A counter with a negative denominator value was detected.
PDH_CALC_NEGATIVE_TIMEBASE0x800007D7A counter with a negative time base value was detected.
PDH_CALC_NEGATIVE_VALUE0x800007D8A counter with a negative value was detected.
PDH_DIALOG_CANCELLED0x800007D9The user canceled the dialog box.
PDH_END_OF_LOG_FILE0x800007DAThe end of the log file was reached.
PDH_ASYNC_QUERY_TIMEOUT0x800007DBA time-out occurred while waiting for the asynchronous counter collection thread to end.
PDH_CANNOT_SET_DEFAULT_REALTIME_DATASOURCE0x800007DCCannot change set default real-time data source. There are real-time query sessions collecting counter data.
PDH_CSTATUS_NO_OBJECT0xC0000BB8The specified object is not found on the system.
PDH_CSTATUS_NO_COUNTER0xC0000BB9The specified counter could not be found.
PDH_CSTATUS_INVALID_DATA0xC0000BBAThe returned data is not valid.
PDH_MEMORY_ALLOCATION_FAILURE0xC0000BBBA PDH function could not allocate enough temporary memory to complete the operation. Close some applications or extend the page file and retry the function.
PDH_INVALID_HANDLE0xC0000BBCThe handle is not a valid PDH object.
PDH_INVALID_ARGUMENT0xC0000BBDA required argument is missing or incorrect.
PDH_FUNCTION_NOT_FOUND0xC0000BBEUnable to find the specified function.
PDH_CSTATUS_NO_COUNTERNAME0xC0000BBFNo counter was specified.
PDH_CSTATUS_BAD_COUNTERNAME0xC0000BC0Unable to parse the counter path. Check the format and syntax of the specified path.
PDH_INVALID_BUFFER0xC0000BC1The buffer passed by the caller is not valid.
PDH_INSUFFICIENT_BUFFER0xC0000BC2The requested data is larger than the buffer supplied. Unable to return the requested data.
PDH_CANNOT_CONNECT_MACHINE0xC0000BC3Unable to connect to the requested computer.
PDH_INVALID_PATH0xC0000BC4The specified counter path could not be interpreted.
PDH_INVALID_INSTANCE0xC0000BC5The instance name could not be read from the specified counter path.
PDH_INVALID_DATA0xC0000BC6The data is not valid.
PDH_NO_DIALOG_DATA0xC0000BC7The dialog box data block was missing or not valid.
PDH_CANNOT_READ_NAME_STRINGS0xC0000BC8Unable to read the counter and/or help text from the specified computer.
PDH_LOG_FILE_CREATE_ERROR0xC0000BC9Unable to create the specified log file.
PDH_LOG_FILE_OPEN_ERROR0xC0000BCAUnable to open the specified log file.
PDH_LOG_TYPE_NOT_FOUND0xC0000BCBThe specified log file type has not been installed on this system.
PDH_NO_MORE_DATA0xC0000BCCNo more data is available.
PDH_ENTRY_NOT_IN_LOG_FILE0xC0000BCDThe specified record was not found in the log file.
PDH_DATA_SOURCE_IS_LOG_FILE0xC0000BCEThe specified data source is a log file.
PDH_DATA_SOURCE_IS_REAL_TIME0xC0000BCFThe specified data source is the current activity.
PDH_UNABLE_READ_LOG_HEADER0xC0000BD0The log file header could not be read.
PDH_FILE_NOT_FOUND0xC0000BD1Unable to find the specified file.
PDH_FILE_ALREADY_EXISTS0xC0000BD2There is already a file with the specified file name.
PDH_NOT_IMPLEMENTED0xC0000BD3The function referenced has not been implemented.
PDH_STRING_NOT_FOUND0xC0000BD4Unable to find the specified string in the list of performance name and help text strings.
PDH_UNABLE_MAP_NAME_FILES0x80000BD5Unable to map to the performance counter name data files. The data will be read from the registry and stored locally.
PDH_UNKNOWN_LOG_FORMAT0xC0000BD6The format of the specified log file is not recognized by the PDH DLL.
PDH_UNKNOWN_LOGSVC_COMMAND0xC0000BD7The specified Log Service command value is not recognized.
PDH_LOGSVC_QUERY_NOT_FOUND0xC0000BD8The specified query from the Log Service could not be found or could not be opened.
PDH_LOGSVC_NOT_OPENED0xC0000BD9The Performance Data Log Service key could not be opened. This may be due to insufficient privilege or because the service has not been installed.
PDH_WBEM_ERROR0xC0000BDAAn error occurred while accessing the WBEM data store.
PDH_ACCESS_DENIED0xC0000BDBUnable to access the desired computer or service. Check the permissions and authentication of the log service or the interactive user session against those on the computer or service being monitored.
PDH_LOG_FILE_TOO_SMALL0xC0000BDCThe maximum log file size specified is too small to log the selected counters. No data will be recorded in this log file. Specify a smaller set of counters to log or a larger file size and retry this call.
PDH_INVALID_DATASOURCE0xC0000BDDCannot connect to ODBC DataSource Name.
PDH_INVALID_SQLDB0xC0000BDESQL Database does not contain a valid set of tables for Perfmon.
PDH_NO_COUNTERS0xC0000BDFNo counters were found for this Perfmon SQL Log Set.
PDH_SQL_ALLOC_FAILED0xC0000BE0Call to SQLAllocStmt failed with %1.
PDH_SQL_ALLOCCON_FAILED0xC0000BE1Call to SQLAllocConnect failed with %1.
PDH_SQL_EXEC_DIRECT_FAILED0xC0000BE2Call to SQLExecDirect failed with %1.
PDH_SQL_FETCH_FAILED0xC0000BE3Call to SQLFetch failed with %1.
PDH_SQL_ROWCOUNT_FAILED0xC0000BE4Call to SQLRowCount failed with %1.
PDH_SQL_MORE_RESULTS_FAILED0xC0000BE5Call to SQLMoreResults failed with %1.
PDH_SQL_CONNECT_FAILED0xC0000BE6Call to SQLConnect failed with %1.
PDH_SQL_BIND_FAILED0xC0000BE7Call to SQLBindCol failed with %1.
PDH_CANNOT_CONNECT_WMI_SERVER0xC0000BE8Unable to connect to the WMI server on requested computer.
PDH_PLA_COLLECTION_ALREADY_RUNNING0xC0000BE9Collection "%1!s!" is already running.
PDH_PLA_ERROR_SCHEDULE_OVERLAP0xC0000BEAThe specified start time is after the end time.
PDH_PLA_COLLECTION_NOT_FOUND0xC0000BEBCollection "%1!s!" does not exist.
PDH_PLA_ERROR_SCHEDULE_ELAPSED0xC0000BECThe specified end time has already elapsed.
PDH_PLA_ERROR_NOSTART0xC0000BEDCollection "%1!s!" did not start; check the application event log for any errors.
PDH_PLA_ERROR_ALREADY_EXISTS0xC0000BEECollection "%1!s!" already exists.
PDH_PLA_ERROR_TYPE_MISMATCH0xC0000BEFThere is a mismatch in the settings type.
PDH_PLA_ERROR_FILEPATH0xC0000BF0The information specified does not resolve to a valid path name.
PDH_PLA_SERVICE_ERROR0xC0000BF1The "Performance Logs & Alerts" service did not respond.
PDH_PLA_VALIDATION_ERROR0xC0000BF2The information passed is not valid.
PDH_PLA_VALIDATION_WARNING0x80000BF3The information passed is not valid.
PDH_PLA_ERROR_NAME_TOO_LONG0xC0000BF4The name supplied is too long.
PDH_INVALID_SQL_LOG_FORMAT0xC0000BF5SQL log format is incorrect. Correct format is SQL:<DSN-name>!<LogSet-Name> .
PDH_COUNTER_ALREADY_IN_QUERY0xC0000BF6Performance counter in PdhAddCounter call has already been added in the performance query. This counter is ignored.
PDH_BINARY_LOG_CORRUPT0xC0000BF7Unable to read counter information and data from input binary log files.
PDH_LOG_SAMPLE_TOO_SMALL0xC0000BF8At least one of the input binary log files contain fewer than two data samples.
PDH_OS_LATER_VERSION0xC0000BF9The version of the operating system on the computer named %1 is later than that on the local computer. This operation is not available from the local computer.
PDH_OS_EARLIER_VERSION0xC0000BFA%1 supports %2 or later. Check the operating system version on the computer named %3.
PDH_INCORRECT_APPEND_TIME0xC0000BFBThe output file must contain earlier data than the file to be appended.
PDH_UNMATCHED_APPEND_COUNTER0xC0000BFCBoth files must have identical counters in order to append.
PDH_SQL_ALTER_DETAIL_FAILED0xC0000BFDCannot alter CounterDetail table layout in SQL database.
PDH_QUERY_PERF_DATA_TIMEOUT0xC0000BFESystem is busy. A time-out occurred when collecting counter data. Please retry later or increase the CollectTime registry value.
86 entries

Article text from the Win32 documentation (opens in a new tab), by Microsoft, under the CC BY 4.0 (opens in a new tab) licence.