ホーム › System.Performance › PerfSetULongLongCounterValue
PerfSetULongLongCounterValue
関数ULongLong型カウンターの値を設定する。
シグネチャ
// ADVAPI32.dll
#include <windows.h>
DWORD PerfSetULongLongCounterValue(
HANDLE Provider,
PERF_COUNTERSET_INSTANCE* Instance,
DWORD CounterId,
ULONGLONG Value
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| Provider | HANDLE | in |
| Instance | PERF_COUNTERSET_INSTANCE* | inout |
| CounterId | DWORD | in |
| Value | ULONGLONG | in |
戻り値の型: DWORD
各言語での呼び出し定義
// ADVAPI32.dll
#include <windows.h>
DWORD PerfSetULongLongCounterValue(
HANDLE Provider,
PERF_COUNTERSET_INSTANCE* Instance,
DWORD CounterId,
ULONGLONG Value
);[DllImport("ADVAPI32.dll", ExactSpelling = true)]
static extern uint PerfSetULongLongCounterValue(
IntPtr Provider, // HANDLE
IntPtr Instance, // PERF_COUNTERSET_INSTANCE* in/out
uint CounterId, // DWORD
ulong Value // ULONGLONG
);<DllImport("ADVAPI32.dll", ExactSpelling:=True)>
Public Shared Function PerfSetULongLongCounterValue(
Provider As IntPtr, ' HANDLE
Instance As IntPtr, ' PERF_COUNTERSET_INSTANCE* in/out
CounterId As UInteger, ' DWORD
Value As ULong ' ULONGLONG
) As UInteger
End Function' Provider : HANDLE
' Instance : PERF_COUNTERSET_INSTANCE* in/out
' CounterId : DWORD
' Value : ULONGLONG
Declare PtrSafe Function PerfSetULongLongCounterValue Lib "advapi32" ( _
ByVal Provider As LongPtr, _
ByVal Instance As LongPtr, _
ByVal CounterId As Long, _
ByVal Value As LongLong) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
PerfSetULongLongCounterValue = ctypes.windll.advapi32.PerfSetULongLongCounterValue
PerfSetULongLongCounterValue.restype = wintypes.DWORD
PerfSetULongLongCounterValue.argtypes = [
wintypes.HANDLE, # Provider : HANDLE
ctypes.c_void_p, # Instance : PERF_COUNTERSET_INSTANCE* in/out
wintypes.DWORD, # CounterId : DWORD
ctypes.c_ulonglong, # Value : ULONGLONG
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ADVAPI32.dll')
PerfSetULongLongCounterValue = Fiddle::Function.new(
lib['PerfSetULongLongCounterValue'],
[
Fiddle::TYPE_VOIDP, # Provider : HANDLE
Fiddle::TYPE_VOIDP, # Instance : PERF_COUNTERSET_INSTANCE* in/out
-Fiddle::TYPE_INT, # CounterId : DWORD
-Fiddle::TYPE_LONG_LONG, # Value : ULONGLONG
],
-Fiddle::TYPE_INT)#[link(name = "advapi32")]
extern "system" {
fn PerfSetULongLongCounterValue(
Provider: *mut core::ffi::c_void, // HANDLE
Instance: *mut PERF_COUNTERSET_INSTANCE, // PERF_COUNTERSET_INSTANCE* in/out
CounterId: u32, // DWORD
Value: u64 // ULONGLONG
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ADVAPI32.dll")]
public static extern uint PerfSetULongLongCounterValue(IntPtr Provider, IntPtr Instance, uint CounterId, ulong Value);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVAPI32_PerfSetULongLongCounterValue' -Namespace Win32 -PassThru
# $api::PerfSetULongLongCounterValue(Provider, Instance, CounterId, Value)#uselib "ADVAPI32.dll"
#func global PerfSetULongLongCounterValue "PerfSetULongLongCounterValue" sptr, sptr, sptr, sptr
; PerfSetULongLongCounterValue Provider, varptr(Instance), CounterId, Value ; 戻り値は stat
; Provider : HANDLE -> "sptr"
; Instance : PERF_COUNTERSET_INSTANCE* in/out -> "sptr"
; CounterId : DWORD -> "sptr"
; Value : ULONGLONG -> "sptr"
; ※HSP3.7は int64 引数(64bit値渡し)に非対応です。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "ADVAPI32.dll" #cfunc global PerfSetULongLongCounterValue "PerfSetULongLongCounterValue" sptr, var, int, int64 ; res = PerfSetULongLongCounterValue(Provider, Instance, CounterId, Value) ; Provider : HANDLE -> "sptr" ; Instance : PERF_COUNTERSET_INSTANCE* in/out -> "var" ; CounterId : DWORD -> "int" ; Value : ULONGLONG -> "int64" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。 ; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。#uselib "ADVAPI32.dll" #cfunc global PerfSetULongLongCounterValue "PerfSetULongLongCounterValue" sptr, sptr, int, int64 ; res = PerfSetULongLongCounterValue(Provider, varptr(Instance), CounterId, Value) ; Provider : HANDLE -> "sptr" ; Instance : PERF_COUNTERSET_INSTANCE* in/out -> "sptr" ; CounterId : DWORD -> "int" ; Value : ULONGLONG -> "int64" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。 ; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。
出力引数:
; DWORD PerfSetULongLongCounterValue(HANDLE Provider, PERF_COUNTERSET_INSTANCE* Instance, DWORD CounterId, ULONGLONG Value) #uselib "ADVAPI32.dll" #cfunc global PerfSetULongLongCounterValue "PerfSetULongLongCounterValue" intptr, var, int, int64 ; res = PerfSetULongLongCounterValue(Provider, Instance, CounterId, Value) ; Provider : HANDLE -> "intptr" ; Instance : PERF_COUNTERSET_INSTANCE* in/out -> "var" ; CounterId : DWORD -> "int" ; Value : ULONGLONG -> "int64" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD PerfSetULongLongCounterValue(HANDLE Provider, PERF_COUNTERSET_INSTANCE* Instance, DWORD CounterId, ULONGLONG Value) #uselib "ADVAPI32.dll" #cfunc global PerfSetULongLongCounterValue "PerfSetULongLongCounterValue" intptr, intptr, int, int64 ; res = PerfSetULongLongCounterValue(Provider, varptr(Instance), CounterId, Value) ; Provider : HANDLE -> "intptr" ; Instance : PERF_COUNTERSET_INSTANCE* in/out -> "intptr" ; CounterId : DWORD -> "int" ; Value : ULONGLONG -> "int64" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
procPerfSetULongLongCounterValue = advapi32.NewProc("PerfSetULongLongCounterValue")
)
// Provider (HANDLE), Instance (PERF_COUNTERSET_INSTANCE* in/out), CounterId (DWORD), Value (ULONGLONG)
r1, _, err := procPerfSetULongLongCounterValue.Call(
uintptr(Provider),
uintptr(Instance),
uintptr(CounterId),
uintptr(Value),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction PerfSetULongLongCounterValue(
Provider: THandle; // HANDLE
Instance: Pointer; // PERF_COUNTERSET_INSTANCE* in/out
CounterId: DWORD; // DWORD
Value: UInt64 // ULONGLONG
): DWORD; stdcall;
external 'ADVAPI32.dll' name 'PerfSetULongLongCounterValue';result := DllCall("ADVAPI32\PerfSetULongLongCounterValue"
, "Ptr", Provider ; HANDLE
, "Ptr", Instance ; PERF_COUNTERSET_INSTANCE* in/out
, "UInt", CounterId ; DWORD
, "Int64", Value ; ULONGLONG
, "UInt") ; return: DWORD●PerfSetULongLongCounterValue(Provider, Instance, CounterId, Value) = DLL("ADVAPI32.dll", "dword PerfSetULongLongCounterValue(void*, void*, dword, qword)")
# 呼び出し: PerfSetULongLongCounterValue(Provider, Instance, CounterId, Value)
# Provider : HANDLE -> "void*"
# Instance : PERF_COUNTERSET_INSTANCE* in/out -> "void*"
# CounterId : DWORD -> "dword"
# Value : ULONGLONG -> "qword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。