ホーム › System.Performance › PdhCalculateCounterFromRawValue
PdhCalculateCounterFromRawValue
関数二つの生値からカウンター値を整形して算出する。
シグネチャ
// pdh.dll
#include <windows.h>
DWORD PdhCalculateCounterFromRawValue(
PDH_HCOUNTER hCounter,
PDH_FMT dwFormat,
PDH_RAW_COUNTER* rawValue1,
PDH_RAW_COUNTER* rawValue2,
PDH_FMT_COUNTERVALUE* fmtValue
);パラメーター
| 名前 | 型 | 方向 | 説明 | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| hCounter | PDH_HCOUNTER | in | 計算対象のカウンターへのハンドルです。この関数は、カウンターの情報を使用して値の計算方法を決定します。このハンドルは PdhAddCounter 関数によって返されます。 | ||||||||
| dwFormat | PDH_FMT | in | 計算結果のデータ型を指定します。次のいずれかの値を指定してください。
ビットごとの論理和演算子 (|) を使用して、データ型を次のいずれかのスケーリング係数と組み合わせることができます。 | ||||||||
| rawValue1 | PDH_RAW_COUNTER* | in | 表示可能なカウンター値の計算に使用する生のカウンター値です。詳細については、PDH_RAW_COUNTER 構造体を参照してください。 | ||||||||
| rawValue2 | PDH_RAW_COUNTER* | in | 表示可能なカウンター値の計算に使用する生のカウンター値です。詳細については、PDH_RAW_COUNTER を参照してください。一部のカウンター (たとえばレート カウンターなど) では、表示可能な値を計算するために 2 つの生の値が必要です。カウンターの種類が 2 番目の値を必要としない場合は、このパラメーターに NULL を設定してください。この値は、2 つの生の値のうち古い方である必要があります。 | ||||||||
| fmtValue | PDH_FMT_COUNTERVALUE* | out | 計算されたカウンター値を受け取る PDH_FMT_COUNTERVALUE 構造体です。 |
戻り値の型: DWORD
公式ドキュメント
2 つの生のカウンター値から、表示可能なカウンター値を計算します。
戻り値
関数が成功した場合は、ERROR_SUCCESS を返します。
関数が失敗した場合は、 システム エラー コードまたは PDH エラー コードが返されます。次の値が返される可能性があります。
| Return code | Description |
|---|---|
| 引数が正しくないか、書式が正しくありません。 | |
| カウンター ハンドルが無効です。 |
解説(Remarks)
クエリから現在の生のカウンター値を取得するには、PdhGetRawCounterValue 関数を呼び出してください。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// pdh.dll
#include <windows.h>
DWORD PdhCalculateCounterFromRawValue(
PDH_HCOUNTER hCounter,
PDH_FMT dwFormat,
PDH_RAW_COUNTER* rawValue1,
PDH_RAW_COUNTER* rawValue2,
PDH_FMT_COUNTERVALUE* fmtValue
);[DllImport("pdh.dll", ExactSpelling = true)]
static extern uint PdhCalculateCounterFromRawValue(
IntPtr hCounter, // PDH_HCOUNTER
uint dwFormat, // PDH_FMT
IntPtr rawValue1, // PDH_RAW_COUNTER*
IntPtr rawValue2, // PDH_RAW_COUNTER*
IntPtr fmtValue // PDH_FMT_COUNTERVALUE* out
);<DllImport("pdh.dll", ExactSpelling:=True)>
Public Shared Function PdhCalculateCounterFromRawValue(
hCounter As IntPtr, ' PDH_HCOUNTER
dwFormat As UInteger, ' PDH_FMT
rawValue1 As IntPtr, ' PDH_RAW_COUNTER*
rawValue2 As IntPtr, ' PDH_RAW_COUNTER*
fmtValue As IntPtr ' PDH_FMT_COUNTERVALUE* out
) As UInteger
End Function' hCounter : PDH_HCOUNTER
' dwFormat : PDH_FMT
' rawValue1 : PDH_RAW_COUNTER*
' rawValue2 : PDH_RAW_COUNTER*
' fmtValue : PDH_FMT_COUNTERVALUE* out
Declare PtrSafe Function PdhCalculateCounterFromRawValue Lib "pdh" ( _
ByVal hCounter As LongPtr, _
ByVal dwFormat As Long, _
ByVal rawValue1 As LongPtr, _
ByVal rawValue2 As LongPtr, _
ByVal fmtValue As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
PdhCalculateCounterFromRawValue = ctypes.windll.pdh.PdhCalculateCounterFromRawValue
PdhCalculateCounterFromRawValue.restype = wintypes.DWORD
PdhCalculateCounterFromRawValue.argtypes = [
wintypes.HANDLE, # hCounter : PDH_HCOUNTER
wintypes.DWORD, # dwFormat : PDH_FMT
ctypes.c_void_p, # rawValue1 : PDH_RAW_COUNTER*
ctypes.c_void_p, # rawValue2 : PDH_RAW_COUNTER*
ctypes.c_void_p, # fmtValue : PDH_FMT_COUNTERVALUE* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('pdh.dll')
PdhCalculateCounterFromRawValue = Fiddle::Function.new(
lib['PdhCalculateCounterFromRawValue'],
[
Fiddle::TYPE_VOIDP, # hCounter : PDH_HCOUNTER
-Fiddle::TYPE_INT, # dwFormat : PDH_FMT
Fiddle::TYPE_VOIDP, # rawValue1 : PDH_RAW_COUNTER*
Fiddle::TYPE_VOIDP, # rawValue2 : PDH_RAW_COUNTER*
Fiddle::TYPE_VOIDP, # fmtValue : PDH_FMT_COUNTERVALUE* out
],
-Fiddle::TYPE_INT)#[link(name = "pdh")]
extern "system" {
fn PdhCalculateCounterFromRawValue(
hCounter: *mut core::ffi::c_void, // PDH_HCOUNTER
dwFormat: u32, // PDH_FMT
rawValue1: *mut PDH_RAW_COUNTER, // PDH_RAW_COUNTER*
rawValue2: *mut PDH_RAW_COUNTER, // PDH_RAW_COUNTER*
fmtValue: *mut PDH_FMT_COUNTERVALUE // PDH_FMT_COUNTERVALUE* out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("pdh.dll")]
public static extern uint PdhCalculateCounterFromRawValue(IntPtr hCounter, uint dwFormat, IntPtr rawValue1, IntPtr rawValue2, IntPtr fmtValue);
"@
$api = Add-Type -MemberDefinition $sig -Name 'pdh_PdhCalculateCounterFromRawValue' -Namespace Win32 -PassThru
# $api::PdhCalculateCounterFromRawValue(hCounter, dwFormat, rawValue1, rawValue2, fmtValue)#uselib "pdh.dll"
#func global PdhCalculateCounterFromRawValue "PdhCalculateCounterFromRawValue" sptr, sptr, sptr, sptr, sptr
; PdhCalculateCounterFromRawValue hCounter, dwFormat, varptr(rawValue1), varptr(rawValue2), varptr(fmtValue) ; 戻り値は stat
; hCounter : PDH_HCOUNTER -> "sptr"
; dwFormat : PDH_FMT -> "sptr"
; rawValue1 : PDH_RAW_COUNTER* -> "sptr"
; rawValue2 : PDH_RAW_COUNTER* -> "sptr"
; fmtValue : PDH_FMT_COUNTERVALUE* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "pdh.dll" #cfunc global PdhCalculateCounterFromRawValue "PdhCalculateCounterFromRawValue" sptr, int, var, var, var ; res = PdhCalculateCounterFromRawValue(hCounter, dwFormat, rawValue1, rawValue2, fmtValue) ; hCounter : PDH_HCOUNTER -> "sptr" ; dwFormat : PDH_FMT -> "int" ; rawValue1 : PDH_RAW_COUNTER* -> "var" ; rawValue2 : PDH_RAW_COUNTER* -> "var" ; fmtValue : PDH_FMT_COUNTERVALUE* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "pdh.dll" #cfunc global PdhCalculateCounterFromRawValue "PdhCalculateCounterFromRawValue" sptr, int, sptr, sptr, sptr ; res = PdhCalculateCounterFromRawValue(hCounter, dwFormat, varptr(rawValue1), varptr(rawValue2), varptr(fmtValue)) ; hCounter : PDH_HCOUNTER -> "sptr" ; dwFormat : PDH_FMT -> "int" ; rawValue1 : PDH_RAW_COUNTER* -> "sptr" ; rawValue2 : PDH_RAW_COUNTER* -> "sptr" ; fmtValue : PDH_FMT_COUNTERVALUE* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD PdhCalculateCounterFromRawValue(PDH_HCOUNTER hCounter, PDH_FMT dwFormat, PDH_RAW_COUNTER* rawValue1, PDH_RAW_COUNTER* rawValue2, PDH_FMT_COUNTERVALUE* fmtValue) #uselib "pdh.dll" #cfunc global PdhCalculateCounterFromRawValue "PdhCalculateCounterFromRawValue" intptr, int, var, var, var ; res = PdhCalculateCounterFromRawValue(hCounter, dwFormat, rawValue1, rawValue2, fmtValue) ; hCounter : PDH_HCOUNTER -> "intptr" ; dwFormat : PDH_FMT -> "int" ; rawValue1 : PDH_RAW_COUNTER* -> "var" ; rawValue2 : PDH_RAW_COUNTER* -> "var" ; fmtValue : PDH_FMT_COUNTERVALUE* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD PdhCalculateCounterFromRawValue(PDH_HCOUNTER hCounter, PDH_FMT dwFormat, PDH_RAW_COUNTER* rawValue1, PDH_RAW_COUNTER* rawValue2, PDH_FMT_COUNTERVALUE* fmtValue) #uselib "pdh.dll" #cfunc global PdhCalculateCounterFromRawValue "PdhCalculateCounterFromRawValue" intptr, int, intptr, intptr, intptr ; res = PdhCalculateCounterFromRawValue(hCounter, dwFormat, varptr(rawValue1), varptr(rawValue2), varptr(fmtValue)) ; hCounter : PDH_HCOUNTER -> "intptr" ; dwFormat : PDH_FMT -> "int" ; rawValue1 : PDH_RAW_COUNTER* -> "intptr" ; rawValue2 : PDH_RAW_COUNTER* -> "intptr" ; fmtValue : PDH_FMT_COUNTERVALUE* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
pdh = windows.NewLazySystemDLL("pdh.dll")
procPdhCalculateCounterFromRawValue = pdh.NewProc("PdhCalculateCounterFromRawValue")
)
// hCounter (PDH_HCOUNTER), dwFormat (PDH_FMT), rawValue1 (PDH_RAW_COUNTER*), rawValue2 (PDH_RAW_COUNTER*), fmtValue (PDH_FMT_COUNTERVALUE* out)
r1, _, err := procPdhCalculateCounterFromRawValue.Call(
uintptr(hCounter),
uintptr(dwFormat),
uintptr(rawValue1),
uintptr(rawValue2),
uintptr(fmtValue),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction PdhCalculateCounterFromRawValue(
hCounter: THandle; // PDH_HCOUNTER
dwFormat: DWORD; // PDH_FMT
rawValue1: Pointer; // PDH_RAW_COUNTER*
rawValue2: Pointer; // PDH_RAW_COUNTER*
fmtValue: Pointer // PDH_FMT_COUNTERVALUE* out
): DWORD; stdcall;
external 'pdh.dll' name 'PdhCalculateCounterFromRawValue';result := DllCall("pdh\PdhCalculateCounterFromRawValue"
, "Ptr", hCounter ; PDH_HCOUNTER
, "UInt", dwFormat ; PDH_FMT
, "Ptr", rawValue1 ; PDH_RAW_COUNTER*
, "Ptr", rawValue2 ; PDH_RAW_COUNTER*
, "Ptr", fmtValue ; PDH_FMT_COUNTERVALUE* out
, "UInt") ; return: DWORD●PdhCalculateCounterFromRawValue(hCounter, dwFormat, rawValue1, rawValue2, fmtValue) = DLL("pdh.dll", "dword PdhCalculateCounterFromRawValue(void*, dword, void*, void*, void*)")
# 呼び出し: PdhCalculateCounterFromRawValue(hCounter, dwFormat, rawValue1, rawValue2, fmtValue)
# hCounter : PDH_HCOUNTER -> "void*"
# dwFormat : PDH_FMT -> "dword"
# rawValue1 : PDH_RAW_COUNTER* -> "void*"
# rawValue2 : PDH_RAW_COUNTER* -> "void*"
# fmtValue : PDH_FMT_COUNTERVALUE* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "pdh" fn PdhCalculateCounterFromRawValue(
hCounter: ?*anyopaque, // PDH_HCOUNTER
dwFormat: u32, // PDH_FMT
rawValue1: [*c]PDH_RAW_COUNTER, // PDH_RAW_COUNTER*
rawValue2: [*c]PDH_RAW_COUNTER, // PDH_RAW_COUNTER*
fmtValue: [*c]PDH_FMT_COUNTERVALUE // PDH_FMT_COUNTERVALUE* out
) callconv(std.os.windows.WINAPI) u32;proc PdhCalculateCounterFromRawValue(
hCounter: pointer, # PDH_HCOUNTER
dwFormat: uint32, # PDH_FMT
rawValue1: ptr PDH_RAW_COUNTER, # PDH_RAW_COUNTER*
rawValue2: ptr PDH_RAW_COUNTER, # PDH_RAW_COUNTER*
fmtValue: ptr PDH_FMT_COUNTERVALUE # PDH_FMT_COUNTERVALUE* out
): uint32 {.importc: "PdhCalculateCounterFromRawValue", stdcall, dynlib: "pdh.dll".}pragma(lib, "pdh");
extern(Windows)
uint PdhCalculateCounterFromRawValue(
void* hCounter, // PDH_HCOUNTER
uint dwFormat, // PDH_FMT
PDH_RAW_COUNTER* rawValue1, // PDH_RAW_COUNTER*
PDH_RAW_COUNTER* rawValue2, // PDH_RAW_COUNTER*
PDH_FMT_COUNTERVALUE* fmtValue // PDH_FMT_COUNTERVALUE* out
);ccall((:PdhCalculateCounterFromRawValue, "pdh.dll"), stdcall, UInt32,
(Ptr{Cvoid}, UInt32, Ptr{PDH_RAW_COUNTER}, Ptr{PDH_RAW_COUNTER}, Ptr{PDH_FMT_COUNTERVALUE}),
hCounter, dwFormat, rawValue1, rawValue2, fmtValue)
# hCounter : PDH_HCOUNTER -> Ptr{Cvoid}
# dwFormat : PDH_FMT -> UInt32
# rawValue1 : PDH_RAW_COUNTER* -> Ptr{PDH_RAW_COUNTER}
# rawValue2 : PDH_RAW_COUNTER* -> Ptr{PDH_RAW_COUNTER}
# fmtValue : PDH_FMT_COUNTERVALUE* out -> Ptr{PDH_FMT_COUNTERVALUE}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t PdhCalculateCounterFromRawValue(
void* hCounter,
uint32_t dwFormat,
void* rawValue1,
void* rawValue2,
void* fmtValue);
]]
local pdh = ffi.load("pdh")
-- pdh.PdhCalculateCounterFromRawValue(hCounter, dwFormat, rawValue1, rawValue2, fmtValue)
-- hCounter : PDH_HCOUNTER
-- dwFormat : PDH_FMT
-- rawValue1 : PDH_RAW_COUNTER*
-- rawValue2 : PDH_RAW_COUNTER*
-- fmtValue : PDH_FMT_COUNTERVALUE* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('pdh.dll');
const PdhCalculateCounterFromRawValue = lib.func('__stdcall', 'PdhCalculateCounterFromRawValue', 'uint32_t', ['void *', 'uint32_t', 'void *', 'void *', 'void *']);
// PdhCalculateCounterFromRawValue(hCounter, dwFormat, rawValue1, rawValue2, fmtValue)
// hCounter : PDH_HCOUNTER -> 'void *'
// dwFormat : PDH_FMT -> 'uint32_t'
// rawValue1 : PDH_RAW_COUNTER* -> 'void *'
// rawValue2 : PDH_RAW_COUNTER* -> 'void *'
// fmtValue : PDH_FMT_COUNTERVALUE* out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("pdh.dll", {
PdhCalculateCounterFromRawValue: { parameters: ["pointer", "u32", "pointer", "pointer", "pointer"], result: "u32" },
});
// lib.symbols.PdhCalculateCounterFromRawValue(hCounter, dwFormat, rawValue1, rawValue2, fmtValue)
// hCounter : PDH_HCOUNTER -> "pointer"
// dwFormat : PDH_FMT -> "u32"
// rawValue1 : PDH_RAW_COUNTER* -> "pointer"
// rawValue2 : PDH_RAW_COUNTER* -> "pointer"
// fmtValue : PDH_FMT_COUNTERVALUE* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t PdhCalculateCounterFromRawValue(
void* hCounter,
uint32_t dwFormat,
void* rawValue1,
void* rawValue2,
void* fmtValue);
C, "pdh.dll");
// $ffi->PdhCalculateCounterFromRawValue(hCounter, dwFormat, rawValue1, rawValue2, fmtValue);
// hCounter : PDH_HCOUNTER
// dwFormat : PDH_FMT
// rawValue1 : PDH_RAW_COUNTER*
// rawValue2 : PDH_RAW_COUNTER*
// fmtValue : PDH_FMT_COUNTERVALUE* out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Pdh extends StdCallLibrary {
Pdh INSTANCE = Native.load("pdh", Pdh.class);
int PdhCalculateCounterFromRawValue(
Pointer hCounter, // PDH_HCOUNTER
int dwFormat, // PDH_FMT
Pointer rawValue1, // PDH_RAW_COUNTER*
Pointer rawValue2, // PDH_RAW_COUNTER*
Pointer fmtValue // PDH_FMT_COUNTERVALUE* out
);
}@[Link("pdh")]
lib Libpdh
fun PdhCalculateCounterFromRawValue = PdhCalculateCounterFromRawValue(
hCounter : Void*, # PDH_HCOUNTER
dwFormat : UInt32, # PDH_FMT
rawValue1 : PDH_RAW_COUNTER*, # PDH_RAW_COUNTER*
rawValue2 : PDH_RAW_COUNTER*, # PDH_RAW_COUNTER*
fmtValue : PDH_FMT_COUNTERVALUE* # PDH_FMT_COUNTERVALUE* out
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef PdhCalculateCounterFromRawValueNative = Uint32 Function(Pointer<Void>, Uint32, Pointer<Void>, Pointer<Void>, Pointer<Void>);
typedef PdhCalculateCounterFromRawValueDart = int Function(Pointer<Void>, int, Pointer<Void>, Pointer<Void>, Pointer<Void>);
final PdhCalculateCounterFromRawValue = DynamicLibrary.open('pdh.dll')
.lookupFunction<PdhCalculateCounterFromRawValueNative, PdhCalculateCounterFromRawValueDart>('PdhCalculateCounterFromRawValue');
// hCounter : PDH_HCOUNTER -> Pointer<Void>
// dwFormat : PDH_FMT -> Uint32
// rawValue1 : PDH_RAW_COUNTER* -> Pointer<Void>
// rawValue2 : PDH_RAW_COUNTER* -> Pointer<Void>
// fmtValue : PDH_FMT_COUNTERVALUE* out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function PdhCalculateCounterFromRawValue(
hCounter: THandle; // PDH_HCOUNTER
dwFormat: DWORD; // PDH_FMT
rawValue1: Pointer; // PDH_RAW_COUNTER*
rawValue2: Pointer; // PDH_RAW_COUNTER*
fmtValue: Pointer // PDH_FMT_COUNTERVALUE* out
): DWORD; stdcall;
external 'pdh.dll' name 'PdhCalculateCounterFromRawValue';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "PdhCalculateCounterFromRawValue"
c_PdhCalculateCounterFromRawValue :: Ptr () -> Word32 -> Ptr () -> Ptr () -> Ptr () -> IO Word32
-- hCounter : PDH_HCOUNTER -> Ptr ()
-- dwFormat : PDH_FMT -> Word32
-- rawValue1 : PDH_RAW_COUNTER* -> Ptr ()
-- rawValue2 : PDH_RAW_COUNTER* -> Ptr ()
-- fmtValue : PDH_FMT_COUNTERVALUE* out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let pdhcalculatecounterfromrawvalue =
foreign "PdhCalculateCounterFromRawValue"
((ptr void) @-> uint32_t @-> (ptr void) @-> (ptr void) @-> (ptr void) @-> returning uint32_t)
(* hCounter : PDH_HCOUNTER -> (ptr void) *)
(* dwFormat : PDH_FMT -> uint32_t *)
(* rawValue1 : PDH_RAW_COUNTER* -> (ptr void) *)
(* rawValue2 : PDH_RAW_COUNTER* -> (ptr void) *)
(* fmtValue : PDH_FMT_COUNTERVALUE* out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library pdh (t "pdh.dll"))
(cffi:use-foreign-library pdh)
(cffi:defcfun ("PdhCalculateCounterFromRawValue" pdh-calculate-counter-from-raw-value :convention :stdcall) :uint32
(h-counter :pointer) ; PDH_HCOUNTER
(dw-format :uint32) ; PDH_FMT
(raw-value1 :pointer) ; PDH_RAW_COUNTER*
(raw-value2 :pointer) ; PDH_RAW_COUNTER*
(fmt-value :pointer)) ; PDH_FMT_COUNTERVALUE* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $PdhCalculateCounterFromRawValue = Win32::API::More->new('pdh',
'DWORD PdhCalculateCounterFromRawValue(HANDLE hCounter, DWORD dwFormat, LPVOID rawValue1, LPVOID rawValue2, LPVOID fmtValue)');
# my $ret = $PdhCalculateCounterFromRawValue->Call($hCounter, $dwFormat, $rawValue1, $rawValue2, $fmtValue);
# hCounter : PDH_HCOUNTER -> HANDLE
# dwFormat : PDH_FMT -> DWORD
# rawValue1 : PDH_RAW_COUNTER* -> LPVOID
# rawValue2 : PDH_RAW_COUNTER* -> LPVOID
# fmtValue : PDH_FMT_COUNTERVALUE* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
公式の関連項目
- f PdhGetFormattedCounterValue — カウンターの値を指定形式に整形して取得する。
- f PdhGetRawCounterValue — カウンターの生の値を取得する。
- f PdhSetCounterScaleFactor — カウンター値に適用する倍率係数を設定する。