QueryPerformanceCounter 関数 (profileapi.h)

パフォーマンス カウンターの現在の値を取得します。これは、時間間隔の測定に使用できる高解像度 (<1us) のタイム スタンプです。

構文

BOOL QueryPerformanceCounter(
  [out] LARGE_INTEGER *lpPerformanceCount
);

パラメーター

[out] lpPerformanceCount

現在のパフォーマンス カウンター値を受け取る変数へのポインター (カウント単位)。

戻り値

関数が成功すると、戻り値は 0 以外になります。

関数が失敗した場合は、0 を返します。 詳細なエラー情報を得るには、GetLastError を呼び出します。 Windows XP 以降を実行するシステムでは、関数は常に成功するため、ゼロは返されません。

注釈

この関数とその使用方法の詳細については、「 高解像度タイム スタンプの取得」を参照してください。

// Gets the current number of ticks from QueryPerformanceCounter. Throws an
// exception if the call to QueryPerformanceCounter fails.
static inline int64_t GetTicks()
{
    LARGE_INTEGER ticks;
    if (!QueryPerformanceCounter(&ticks))
    {
        winrt::throw_last_error();
    }
    return ticks.QuadPart;
}

要件

要件
サポートされている最小のクライアント Windows 2000 Professional [デスクトップ アプリ |UWP アプリ]
サポートされている最小のサーバー Windows 2000 Server [デスクトップ アプリ |UWP アプリ]
対象プラットフォーム Windows
ヘッダー profileapi.h (Windows.h を含む)
Library Kernel32.lib
[DLL] Kernel32.dll

関連項目

高解像度タイム スタンプの取得

概念

GetSystemTimePreciseAsFileTime

KeQueryPerformanceCounter

QueryPerformanceFrequency

リファレンス

Time

タイマー