Win32 API 日本語リファレンス
ホームUI.WindowsAndMessaging › IsGUIThread

IsGUIThread

関数
呼び出しスレッドがGUIスレッドか判定し変換する。
DLLUSER32.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

BOOL IsGUIThread(
    BOOL bConvert
);

パラメーター

名前方向
bConvertBOOLin

戻り値の型: BOOL

各言語での呼び出し定義

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

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

IsGUIThread = ctypes.windll.user32.IsGUIThread
IsGUIThread.restype = wintypes.BOOL
IsGUIThread.argtypes = [
    wintypes.BOOL,  # bConvert : BOOL
]
require 'fiddle'
require 'fiddle/import'

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

var (
	user32 = windows.NewLazySystemDLL("USER32.dll")
	procIsGUIThread = user32.NewProc("IsGUIThread")
)

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