ConvertAuxiliaryCounterToPerformanceCounter function

Converts the specified auxiliary counter value to the corresponding performance counter value; optionally provides the estimated conversion error in nanoseconds due to latencies and maximum possible drift.

Syntax


HRESULT WINAPI ConvertAuxiliaryCounterToPerformanceCounter(
  _In_      ULONGLONG  ullAuxiliaryCounterValue,
  _Out_     PULONGLONG lpPerformanceCounterValue,
  _Out_opt_ PULONGLONG lpConversionError
);

Parameters

ullAuxiliaryCounterValue [in]

The auxiliary counter value to convert.

lpPerformanceCounterValue [out]

On success, contains the converted performance counter value. Will be undefined if the function fails.

lpConversionError [out, optional]

On success, contains the estimated conversion error, in nanoseconds. Will be undefined if the function fails.

Return value

Returns S_OK if the conversion succeeds; otherwise, returns another HRESULT specifying the error.

Return valueDescription
S_OK

The function succeeded.

E_NOTIMPL

The auxiliary counter is not supported.

E_BOUNDS

The value to convert is outside the permitted range (+/- 10 seconds from when the called occurred).

 

Examples

The following code sample shows how to call ConvertPerformanceCounterToAuxiliaryCounter and ConvertAuxiliaryCounterToPerformanceCounter to convert the specified data.


#include <stdio.h> 
#include <windows.h> 
int 
wmain (int argc, wchar_t* argv[]) 
{

ULONGLONG AuxiliaryCounter;
ULONGLONG ConversionError;
LARGE_INTEGER PerformanceCounter;
HRESULT Result;

Result = QueryPerformanceCounter(&PerformanceCounter);
if (FAILED(Result)) {
    wprintf(L"Failed to retrieve performance counter.\n");
    return 0;
}

Result = ConvertPerformanceCounterToAuxiliaryCounter(
             PerformanceCounter.QuadPart,
             &AuxiliaryCounter,
             &ConversionError);

if (SUCCEEDED(Result)) {
    wprintf(L"Performance counter to convert is: %llu, "
            L"Auxiliary counter converted is: %llu, "
            L"Conversion error is: %llu.\n",
            PerformanceCounter.QuadPart, AuxiliaryCounter, ConversionError);

} else {
    wprintf(L"Failed to convert performance counter to auxiliary counter.\n");
    return 0;
 
}

Result = ConvertAuxiliaryCounterToPerformanceCounter(
             AuxiliaryCounter,
             &(PerformanceCounter.QuadPart),
             &ConversionError);

if (SUCCEEDED(Result)) {
    wprintf(L"Auxiliary counter to convert is: %llu, "
            L"Performance counter converted is: %llu, "
            L"Conversion error is: %llu.\n",
            AuxiliaryCounter, PerformanceCounter.QuadPart, ConversionError);

} else {
    wprintf(L"Failed to convert auxiliary counter to performance counter.\n");
    return 0;
 
}

    return 0; 
} 


Requirements

Minimum supported client

Windows 10, version 1703 [desktop apps only]

Minimum supported server

Windows Server 2016 [desktop apps only]

Header

Realtimeapiset.h

Library

Mincore.lib

DLL

Kernel32.dll

 

 

Show: