擷取效能計數器的當前值,該計數器為高解析度(<1 單位)時間戳記,可用於時間區間測量。
語法
BOOL QueryPerformanceCounter(
[out] LARGE_INTEGER *lpPerformanceCount
);
參數
[out] lpPerformanceCount
指向一個接收當前效能計數器值的變數指標,計數。
返回值
如果函式成功,則傳回值為非零值。
如果函式失敗,傳回值為零。 若要取得擴充的錯誤資訊,請呼叫 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;
}
需求
| Requirement | 價值觀 |
|---|---|
| 最低支援的用戶端 | Windows 2000 專業版 [傳統型應用程式 |UWP 應用程式] |
| 支援的最低伺服器 | Windows 2000 Server [傳統型應用程式 |UWP 應用程式] |
| 目標平臺 | 窗戶 |
| Header | profileapi.h(包含 Windows.h) |
| Library | Kernel32.lib |
| DLL | Kernel32.dll |
另請參閱
概念
GetSystemTimePreciseAsFileTime
參考