Win32 API 日本語リファレンス
ホームSystem.Performance.HardwareCounterProfiling › QueryThreadProfiling

QueryThreadProfiling

関数
指定スレッドのプロファイリングが有効か照会する。
DLLKERNEL32.dll呼出規約winapi対応OSWindows 7 以降

シグネチャ

// KERNEL32.dll
#include <windows.h>

DWORD QueryThreadProfiling(
    HANDLE ThreadHandle,
    BOOLEAN* Enabled
);

パラメーター

名前方向
ThreadHandleHANDLEin
EnabledBOOLEAN*out

戻り値の型: DWORD

各言語での呼び出し定義

// KERNEL32.dll
#include <windows.h>

DWORD QueryThreadProfiling(
    HANDLE ThreadHandle,
    BOOLEAN* Enabled
);
[DllImport("KERNEL32.dll", ExactSpelling = true)]
static extern uint QueryThreadProfiling(
    IntPtr ThreadHandle,   // HANDLE
    out byte Enabled   // BOOLEAN* out
);
<DllImport("KERNEL32.dll", ExactSpelling:=True)>
Public Shared Function QueryThreadProfiling(
    ThreadHandle As IntPtr,   ' HANDLE
    <Out> ByRef Enabled As Byte   ' BOOLEAN* out
) As UInteger
End Function
' ThreadHandle : HANDLE
' Enabled : BOOLEAN* out
Declare PtrSafe Function QueryThreadProfiling Lib "kernel32" ( _
    ByVal ThreadHandle As LongPtr, _
    ByRef Enabled As Byte) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

QueryThreadProfiling = ctypes.windll.kernel32.QueryThreadProfiling
QueryThreadProfiling.restype = wintypes.DWORD
QueryThreadProfiling.argtypes = [
    wintypes.HANDLE,  # ThreadHandle : HANDLE
    ctypes.c_void_p,  # Enabled : BOOLEAN* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('KERNEL32.dll')
QueryThreadProfiling = Fiddle::Function.new(
  lib['QueryThreadProfiling'],
  [
    Fiddle::TYPE_VOIDP,  # ThreadHandle : HANDLE
    Fiddle::TYPE_VOIDP,  # Enabled : BOOLEAN* out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "kernel32")]
extern "system" {
    fn QueryThreadProfiling(
        ThreadHandle: *mut core::ffi::c_void,  // HANDLE
        Enabled: *mut u8  // BOOLEAN* out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("KERNEL32.dll")]
public static extern uint QueryThreadProfiling(IntPtr ThreadHandle, out byte Enabled);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_QueryThreadProfiling' -Namespace Win32 -PassThru
# $api::QueryThreadProfiling(ThreadHandle, Enabled)
#uselib "KERNEL32.dll"
#func global QueryThreadProfiling "QueryThreadProfiling" sptr, sptr
; QueryThreadProfiling ThreadHandle, Enabled   ; 戻り値は stat
; ThreadHandle : HANDLE -> "sptr"
; Enabled : BOOLEAN* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "KERNEL32.dll"
#cfunc global QueryThreadProfiling "QueryThreadProfiling" sptr, int
; res = QueryThreadProfiling(ThreadHandle, Enabled)
; ThreadHandle : HANDLE -> "sptr"
; Enabled : BOOLEAN* out -> "int"
; DWORD QueryThreadProfiling(HANDLE ThreadHandle, BOOLEAN* Enabled)
#uselib "KERNEL32.dll"
#cfunc global QueryThreadProfiling "QueryThreadProfiling" intptr, int
; res = QueryThreadProfiling(ThreadHandle, Enabled)
; ThreadHandle : HANDLE -> "intptr"
; Enabled : BOOLEAN* out -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procQueryThreadProfiling = kernel32.NewProc("QueryThreadProfiling")
)

// ThreadHandle (HANDLE), Enabled (BOOLEAN* out)
r1, _, err := procQueryThreadProfiling.Call(
	uintptr(ThreadHandle),
	uintptr(Enabled),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function QueryThreadProfiling(
  ThreadHandle: THandle;   // HANDLE
  Enabled: Pointer   // BOOLEAN* out
): DWORD; stdcall;
  external 'KERNEL32.dll' name 'QueryThreadProfiling';
result := DllCall("KERNEL32\QueryThreadProfiling"
    , "Ptr", ThreadHandle   ; HANDLE
    , "Ptr", Enabled   ; BOOLEAN* out
    , "UInt")   ; return: DWORD
●QueryThreadProfiling(ThreadHandle, Enabled) = DLL("KERNEL32.dll", "dword QueryThreadProfiling(void*, void*)")
# 呼び出し: QueryThreadProfiling(ThreadHandle, Enabled)
# ThreadHandle : HANDLE -> "void*"
# Enabled : BOOLEAN* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。