ホーム › System.Performance › PdhSetLogSetRunID
PdhSetLogSetRunID
関数ログセットの実行IDを設定する。
シグネチャ
// pdh.dll
#include <windows.h>
DWORD PdhSetLogSetRunID(
PDH_HLOG hLog,
INT RunId
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hLog | PDH_HLOG | inout | 実行IDを設定する対象ログのハンドルを指定する。 |
| RunId | INT | in | ログセットに設定する実行ID(RunId)を指定する。 |
戻り値の型: DWORD
各言語での呼び出し定義
// pdh.dll
#include <windows.h>
DWORD PdhSetLogSetRunID(
PDH_HLOG hLog,
INT RunId
);[DllImport("pdh.dll", ExactSpelling = true)]
static extern uint PdhSetLogSetRunID(
IntPtr hLog, // PDH_HLOG in/out
int RunId // INT
);<DllImport("pdh.dll", ExactSpelling:=True)>
Public Shared Function PdhSetLogSetRunID(
hLog As IntPtr, ' PDH_HLOG in/out
RunId As Integer ' INT
) As UInteger
End Function' hLog : PDH_HLOG in/out
' RunId : INT
Declare PtrSafe Function PdhSetLogSetRunID Lib "pdh" ( _
ByVal hLog As LongPtr, _
ByVal RunId As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
PdhSetLogSetRunID = ctypes.windll.pdh.PdhSetLogSetRunID
PdhSetLogSetRunID.restype = wintypes.DWORD
PdhSetLogSetRunID.argtypes = [
wintypes.HANDLE, # hLog : PDH_HLOG in/out
ctypes.c_int, # RunId : INT
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('pdh.dll')
PdhSetLogSetRunID = Fiddle::Function.new(
lib['PdhSetLogSetRunID'],
[
Fiddle::TYPE_VOIDP, # hLog : PDH_HLOG in/out
Fiddle::TYPE_INT, # RunId : INT
],
-Fiddle::TYPE_INT)#[link(name = "pdh")]
extern "system" {
fn PdhSetLogSetRunID(
hLog: *mut core::ffi::c_void, // PDH_HLOG in/out
RunId: i32 // INT
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("pdh.dll")]
public static extern uint PdhSetLogSetRunID(IntPtr hLog, int RunId);
"@
$api = Add-Type -MemberDefinition $sig -Name 'pdh_PdhSetLogSetRunID' -Namespace Win32 -PassThru
# $api::PdhSetLogSetRunID(hLog, RunId)#uselib "pdh.dll"
#func global PdhSetLogSetRunID "PdhSetLogSetRunID" sptr, sptr
; PdhSetLogSetRunID hLog, RunId ; 戻り値は stat
; hLog : PDH_HLOG in/out -> "sptr"
; RunId : INT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "pdh.dll"
#cfunc global PdhSetLogSetRunID "PdhSetLogSetRunID" sptr, int
; res = PdhSetLogSetRunID(hLog, RunId)
; hLog : PDH_HLOG in/out -> "sptr"
; RunId : INT -> "int"; DWORD PdhSetLogSetRunID(PDH_HLOG hLog, INT RunId)
#uselib "pdh.dll"
#cfunc global PdhSetLogSetRunID "PdhSetLogSetRunID" intptr, int
; res = PdhSetLogSetRunID(hLog, RunId)
; hLog : PDH_HLOG in/out -> "intptr"
; RunId : INT -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
pdh = windows.NewLazySystemDLL("pdh.dll")
procPdhSetLogSetRunID = pdh.NewProc("PdhSetLogSetRunID")
)
// hLog (PDH_HLOG in/out), RunId (INT)
r1, _, err := procPdhSetLogSetRunID.Call(
uintptr(hLog),
uintptr(RunId),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction PdhSetLogSetRunID(
hLog: THandle; // PDH_HLOG in/out
RunId: Integer // INT
): DWORD; stdcall;
external 'pdh.dll' name 'PdhSetLogSetRunID';result := DllCall("pdh\PdhSetLogSetRunID"
, "Ptr", hLog ; PDH_HLOG in/out
, "Int", RunId ; INT
, "UInt") ; return: DWORD●PdhSetLogSetRunID(hLog, RunId) = DLL("pdh.dll", "dword PdhSetLogSetRunID(void*, int)")
# 呼び出し: PdhSetLogSetRunID(hLog, RunId)
# hLog : PDH_HLOG in/out -> "void*"
# RunId : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "pdh" fn PdhSetLogSetRunID(
hLog: ?*anyopaque, // PDH_HLOG in/out
RunId: i32 // INT
) callconv(std.os.windows.WINAPI) u32;proc PdhSetLogSetRunID(
hLog: pointer, # PDH_HLOG in/out
RunId: int32 # INT
): uint32 {.importc: "PdhSetLogSetRunID", stdcall, dynlib: "pdh.dll".}pragma(lib, "pdh");
extern(Windows)
uint PdhSetLogSetRunID(
void* hLog, // PDH_HLOG in/out
int RunId // INT
);ccall((:PdhSetLogSetRunID, "pdh.dll"), stdcall, UInt32,
(Ptr{Cvoid}, Int32),
hLog, RunId)
# hLog : PDH_HLOG in/out -> Ptr{Cvoid}
# RunId : INT -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t PdhSetLogSetRunID(
void* hLog,
int32_t RunId);
]]
local pdh = ffi.load("pdh")
-- pdh.PdhSetLogSetRunID(hLog, RunId)
-- hLog : PDH_HLOG in/out
-- RunId : INT
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('pdh.dll');
const PdhSetLogSetRunID = lib.func('__stdcall', 'PdhSetLogSetRunID', 'uint32_t', ['void *', 'int32_t']);
// PdhSetLogSetRunID(hLog, RunId)
// hLog : PDH_HLOG in/out -> 'void *'
// RunId : INT -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("pdh.dll", {
PdhSetLogSetRunID: { parameters: ["pointer", "i32"], result: "u32" },
});
// lib.symbols.PdhSetLogSetRunID(hLog, RunId)
// hLog : PDH_HLOG in/out -> "pointer"
// RunId : INT -> "i32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t PdhSetLogSetRunID(
void* hLog,
int32_t RunId);
C, "pdh.dll");
// $ffi->PdhSetLogSetRunID(hLog, RunId);
// hLog : PDH_HLOG in/out
// RunId : INT
// 構造体/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 PdhSetLogSetRunID(
Pointer hLog, // PDH_HLOG in/out
int RunId // INT
);
}@[Link("pdh")]
lib Libpdh
fun PdhSetLogSetRunID = PdhSetLogSetRunID(
hLog : Void*, # PDH_HLOG in/out
RunId : Int32 # INT
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef PdhSetLogSetRunIDNative = Uint32 Function(Pointer<Void>, Int32);
typedef PdhSetLogSetRunIDDart = int Function(Pointer<Void>, int);
final PdhSetLogSetRunID = DynamicLibrary.open('pdh.dll')
.lookupFunction<PdhSetLogSetRunIDNative, PdhSetLogSetRunIDDart>('PdhSetLogSetRunID');
// hLog : PDH_HLOG in/out -> Pointer<Void>
// RunId : INT -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function PdhSetLogSetRunID(
hLog: THandle; // PDH_HLOG in/out
RunId: Integer // INT
): DWORD; stdcall;
external 'pdh.dll' name 'PdhSetLogSetRunID';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "PdhSetLogSetRunID"
c_PdhSetLogSetRunID :: Ptr () -> Int32 -> IO Word32
-- hLog : PDH_HLOG in/out -> Ptr ()
-- RunId : INT -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let pdhsetlogsetrunid =
foreign "PdhSetLogSetRunID"
((ptr void) @-> int32_t @-> returning uint32_t)
(* hLog : PDH_HLOG in/out -> (ptr void) *)
(* RunId : INT -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library pdh (t "pdh.dll"))
(cffi:use-foreign-library pdh)
(cffi:defcfun ("PdhSetLogSetRunID" pdh-set-log-set-run-id :convention :stdcall) :uint32
(h-log :pointer) ; PDH_HLOG in/out
(run-id :int32)) ; INT
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $PdhSetLogSetRunID = Win32::API::More->new('pdh',
'DWORD PdhSetLogSetRunID(HANDLE hLog, int RunId)');
# my $ret = $PdhSetLogSetRunID->Call($hLog, $RunId);
# hLog : PDH_HLOG in/out -> HANDLE
# RunId : INT -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。