Win32 API 日本語リファレンス
ホームSystem.Threading › IsThreadpoolTimerSet

IsThreadpoolTimerSet

関数
スレッドプールタイマーが設定済みか判定する。
DLLKERNEL32.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

BOOL IsThreadpoolTimerSet(
    PTP_TIMER pti
);

パラメーター

名前方向説明
ptiPTP_TIMERinタイマーオブジェクトを定義する TP_TIMER 構造体へのポインター。このポインターは CreateThreadpoolTimer 関数によって返されます。

戻り値の型: BOOL

公式ドキュメント

指定したタイマーオブジェクトが現在設定されているかどうかを判定します。

戻り値

タイマーが設定されている場合は TRUE を返し、それ以外の場合は FALSE を返します。

解説(Remarks)

タイマーは、直近の SetThreadpoolTimer または SetThreadpoolTimerEx 関数 の呼び出しで pftDueTime に非 NULL の値が渡された場合に、設定済みと見なされます。

この関数を使用するアプリケーションをコンパイルするには、_WIN32_WINNT を 0x0600 以上として定義してください。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

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

BOOL IsThreadpoolTimerSet(
    PTP_TIMER pti
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", ExactSpelling = true)]
static extern bool IsThreadpoolTimerSet(
    IntPtr pti   // PTP_TIMER
);
<DllImport("KERNEL32.dll", ExactSpelling:=True)>
Public Shared Function IsThreadpoolTimerSet(
    pti As IntPtr   ' PTP_TIMER
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
' pti : PTP_TIMER
Declare PtrSafe Function IsThreadpoolTimerSet Lib "kernel32" ( _
    ByVal pti As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

IsThreadpoolTimerSet = ctypes.windll.kernel32.IsThreadpoolTimerSet
IsThreadpoolTimerSet.restype = wintypes.BOOL
IsThreadpoolTimerSet.argtypes = [
    ctypes.c_ssize_t,  # pti : PTP_TIMER
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('KERNEL32.dll')
IsThreadpoolTimerSet = Fiddle::Function.new(
  lib['IsThreadpoolTimerSet'],
  [
    Fiddle::TYPE_INTPTR_T,  # pti : PTP_TIMER
  ],
  Fiddle::TYPE_INT)
#[link(name = "kernel32")]
extern "system" {
    fn IsThreadpoolTimerSet(
        pti: isize  // PTP_TIMER
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll")]
public static extern bool IsThreadpoolTimerSet(IntPtr pti);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_IsThreadpoolTimerSet' -Namespace Win32 -PassThru
# $api::IsThreadpoolTimerSet(pti)
#uselib "KERNEL32.dll"
#func global IsThreadpoolTimerSet "IsThreadpoolTimerSet" sptr
; IsThreadpoolTimerSet pti   ; 戻り値は stat
; pti : PTP_TIMER -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "KERNEL32.dll"
#cfunc global IsThreadpoolTimerSet "IsThreadpoolTimerSet" sptr
; res = IsThreadpoolTimerSet(pti)
; pti : PTP_TIMER -> "sptr"
; BOOL IsThreadpoolTimerSet(PTP_TIMER pti)
#uselib "KERNEL32.dll"
#cfunc global IsThreadpoolTimerSet "IsThreadpoolTimerSet" intptr
; res = IsThreadpoolTimerSet(pti)
; pti : PTP_TIMER -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procIsThreadpoolTimerSet = kernel32.NewProc("IsThreadpoolTimerSet")
)

// pti (PTP_TIMER)
r1, _, err := procIsThreadpoolTimerSet.Call(
	uintptr(pti),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function IsThreadpoolTimerSet(
  pti: NativeInt   // PTP_TIMER
): BOOL; stdcall;
  external 'KERNEL32.dll' name 'IsThreadpoolTimerSet';
result := DllCall("KERNEL32\IsThreadpoolTimerSet"
    , "Ptr", pti   ; PTP_TIMER
    , "Int")   ; return: BOOL
●IsThreadpoolTimerSet(pti) = DLL("KERNEL32.dll", "bool IsThreadpoolTimerSet(int)")
# 呼び出し: IsThreadpoolTimerSet(pti)
# pti : PTP_TIMER -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "kernel32" fn IsThreadpoolTimerSet(
    pti: isize // PTP_TIMER
) callconv(std.os.windows.WINAPI) i32;
proc IsThreadpoolTimerSet(
    pti: int  # PTP_TIMER
): int32 {.importc: "IsThreadpoolTimerSet", stdcall, dynlib: "KERNEL32.dll".}
pragma(lib, "kernel32");
extern(Windows)
int IsThreadpoolTimerSet(
    ptrdiff_t pti   // PTP_TIMER
);
ccall((:IsThreadpoolTimerSet, "KERNEL32.dll"), stdcall, Int32,
      (Int,),
      pti)
# pti : PTP_TIMER -> Int
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t IsThreadpoolTimerSet(
    intptr_t pti);
]]
local kernel32 = ffi.load("kernel32")
-- kernel32.IsThreadpoolTimerSet(pti)
-- pti : PTP_TIMER
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('KERNEL32.dll');
const IsThreadpoolTimerSet = lib.func('__stdcall', 'IsThreadpoolTimerSet', 'int32_t', ['intptr_t']);
// IsThreadpoolTimerSet(pti)
// pti : PTP_TIMER -> 'intptr_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("KERNEL32.dll", {
  IsThreadpoolTimerSet: { parameters: ["isize"], result: "i32" },
});
// lib.symbols.IsThreadpoolTimerSet(pti)
// pti : PTP_TIMER -> "isize"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t IsThreadpoolTimerSet(
    intptr_t pti);
C, "KERNEL32.dll");
// $ffi->IsThreadpoolTimerSet(pti);
// pti : PTP_TIMER
// 構造体/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 Kernel32 extends StdCallLibrary {
    Kernel32 INSTANCE = Native.load("kernel32", Kernel32.class);
    boolean IsThreadpoolTimerSet(
        long pti   // PTP_TIMER
    );
}
@[Link("kernel32")]
lib LibKERNEL32
  fun IsThreadpoolTimerSet = IsThreadpoolTimerSet(
    pti : LibC::SSizeT   # PTP_TIMER
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef IsThreadpoolTimerSetNative = Int32 Function(IntPtr);
typedef IsThreadpoolTimerSetDart = int Function(int);
final IsThreadpoolTimerSet = DynamicLibrary.open('KERNEL32.dll')
    .lookupFunction<IsThreadpoolTimerSetNative, IsThreadpoolTimerSetDart>('IsThreadpoolTimerSet');
// pti : PTP_TIMER -> IntPtr
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function IsThreadpoolTimerSet(
  pti: NativeInt   // PTP_TIMER
): BOOL; stdcall;
  external 'KERNEL32.dll' name 'IsThreadpoolTimerSet';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "IsThreadpoolTimerSet"
  c_IsThreadpoolTimerSet :: CIntPtr -> IO CInt
-- pti : PTP_TIMER -> CIntPtr
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let isthreadpooltimerset =
  foreign "IsThreadpoolTimerSet"
    (intptr_t @-> returning int32_t)
(* pti : PTP_TIMER -> intptr_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library kernel32 (t "KERNEL32.dll"))
(cffi:use-foreign-library kernel32)

(cffi:defcfun ("IsThreadpoolTimerSet" is-threadpool-timer-set :convention :stdcall) :int32
  (pti :int64))   ; PTP_TIMER
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $IsThreadpoolTimerSet = Win32::API::More->new('KERNEL32',
    'BOOL IsThreadpoolTimerSet(LPARAM pti)');
# my $ret = $IsThreadpoolTimerSet->Call($pti);
# pti : PTP_TIMER -> LPARAM
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

公式の関連項目