ホーム › System.Threading › AttachThreadInput
AttachThreadInput
関数あるスレッドの入力処理を別スレッドに接続または切断する。
シグネチャ
// USER32.dll
#include <windows.h>
BOOL AttachThreadInput(
DWORD idAttach,
DWORD idAttachTo,
BOOL fAttach
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| idAttach | DWORD | in |
| idAttachTo | DWORD | in |
| fAttach | BOOL | in |
戻り値の型: BOOL
各言語での呼び出し定義
// USER32.dll
#include <windows.h>
BOOL AttachThreadInput(
DWORD idAttach,
DWORD idAttachTo,
BOOL fAttach
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", ExactSpelling = true)]
static extern bool AttachThreadInput(
uint idAttach, // DWORD
uint idAttachTo, // DWORD
bool fAttach // BOOL
);<DllImport("USER32.dll", ExactSpelling:=True)>
Public Shared Function AttachThreadInput(
idAttach As UInteger, ' DWORD
idAttachTo As UInteger, ' DWORD
fAttach As Boolean ' BOOL
) As Boolean
End Function' idAttach : DWORD
' idAttachTo : DWORD
' fAttach : BOOL
Declare PtrSafe Function AttachThreadInput Lib "user32" ( _
ByVal idAttach As Long, _
ByVal idAttachTo As Long, _
ByVal fAttach As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
AttachThreadInput = ctypes.windll.user32.AttachThreadInput
AttachThreadInput.restype = wintypes.BOOL
AttachThreadInput.argtypes = [
wintypes.DWORD, # idAttach : DWORD
wintypes.DWORD, # idAttachTo : DWORD
wintypes.BOOL, # fAttach : BOOL
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('USER32.dll')
AttachThreadInput = Fiddle::Function.new(
lib['AttachThreadInput'],
[
-Fiddle::TYPE_INT, # idAttach : DWORD
-Fiddle::TYPE_INT, # idAttachTo : DWORD
Fiddle::TYPE_INT, # fAttach : BOOL
],
Fiddle::TYPE_INT)#[link(name = "user32")]
extern "system" {
fn AttachThreadInput(
idAttach: u32, // DWORD
idAttachTo: u32, // DWORD
fAttach: 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 AttachThreadInput(uint idAttach, uint idAttachTo, bool fAttach);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_AttachThreadInput' -Namespace Win32 -PassThru
# $api::AttachThreadInput(idAttach, idAttachTo, fAttach)#uselib "USER32.dll"
#func global AttachThreadInput "AttachThreadInput" sptr, sptr, sptr
; AttachThreadInput idAttach, idAttachTo, fAttach ; 戻り値は stat
; idAttach : DWORD -> "sptr"
; idAttachTo : DWORD -> "sptr"
; fAttach : BOOL -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "USER32.dll"
#cfunc global AttachThreadInput "AttachThreadInput" int, int, int
; res = AttachThreadInput(idAttach, idAttachTo, fAttach)
; idAttach : DWORD -> "int"
; idAttachTo : DWORD -> "int"
; fAttach : BOOL -> "int"; BOOL AttachThreadInput(DWORD idAttach, DWORD idAttachTo, BOOL fAttach)
#uselib "USER32.dll"
#cfunc global AttachThreadInput "AttachThreadInput" int, int, int
; res = AttachThreadInput(idAttach, idAttachTo, fAttach)
; idAttach : DWORD -> "int"
; idAttachTo : DWORD -> "int"
; fAttach : BOOL -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
user32 = windows.NewLazySystemDLL("USER32.dll")
procAttachThreadInput = user32.NewProc("AttachThreadInput")
)
// idAttach (DWORD), idAttachTo (DWORD), fAttach (BOOL)
r1, _, err := procAttachThreadInput.Call(
uintptr(idAttach),
uintptr(idAttachTo),
uintptr(fAttach),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction AttachThreadInput(
idAttach: DWORD; // DWORD
idAttachTo: DWORD; // DWORD
fAttach: BOOL // BOOL
): BOOL; stdcall;
external 'USER32.dll' name 'AttachThreadInput';result := DllCall("USER32\AttachThreadInput"
, "UInt", idAttach ; DWORD
, "UInt", idAttachTo ; DWORD
, "Int", fAttach ; BOOL
, "Int") ; return: BOOL●AttachThreadInput(idAttach, idAttachTo, fAttach) = DLL("USER32.dll", "bool AttachThreadInput(dword, dword, bool)")
# 呼び出し: AttachThreadInput(idAttach, idAttachTo, fAttach)
# idAttach : DWORD -> "dword"
# idAttachTo : DWORD -> "dword"
# fAttach : BOOL -> "bool"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。