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