Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

ConvertPerformanceCounterToAuxiliaryCounter function

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

Syntax


HRESULT WINAPI ConvertPerformanceCounterToAuxiliaryCounter(
  _In_      ULONGLONG  ullPerformanceCounterValue,
  _Out_     PULONGLONG lpAuxiliaryCounterValue,
  _Out_opt_ PULONGLONG lpConversionError
);

Parameters

ullPerformanceCounterValue [in]

The performance counter value to convert.

lpAuxiliaryCounterValue [out]

On success, contains the converted auxiliary 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).

E_BOUNDS

The value to convert is prior to the last system boot or S3/S4 transition.

 

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:
© 2017 Microsoft