ホーム › System.StationsAndDesktops › SetThreadDesktop
SetThreadDesktop
関数呼び出しスレッドに関連付けるデスクトップを設定する。
シグネチャ
// USER32.dll
#include <windows.h>
BOOL SetThreadDesktop(
HDESK hDesktop
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hDesktop | HDESK | in |
戻り値の型: BOOL
各言語での呼び出し定義
// USER32.dll
#include <windows.h>
BOOL SetThreadDesktop(
HDESK hDesktop
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool SetThreadDesktop(
IntPtr hDesktop // HDESK
);<DllImport("USER32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetThreadDesktop(
hDesktop As IntPtr ' HDESK
) As Boolean
End Function' hDesktop : HDESK
Declare PtrSafe Function SetThreadDesktop Lib "user32" ( _
ByVal hDesktop As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SetThreadDesktop = ctypes.windll.user32.SetThreadDesktop
SetThreadDesktop.restype = wintypes.BOOL
SetThreadDesktop.argtypes = [
wintypes.HANDLE, # hDesktop : HDESK
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('USER32.dll')
SetThreadDesktop = Fiddle::Function.new(
lib['SetThreadDesktop'],
[
Fiddle::TYPE_VOIDP, # hDesktop : HDESK
],
Fiddle::TYPE_INT)#[link(name = "user32")]
extern "system" {
fn SetThreadDesktop(
hDesktop: *mut core::ffi::c_void // HDESK
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", SetLastError = true)]
public static extern bool SetThreadDesktop(IntPtr hDesktop);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_SetThreadDesktop' -Namespace Win32 -PassThru
# $api::SetThreadDesktop(hDesktop)#uselib "USER32.dll"
#func global SetThreadDesktop "SetThreadDesktop" sptr
; SetThreadDesktop hDesktop ; 戻り値は stat
; hDesktop : HDESK -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "USER32.dll"
#cfunc global SetThreadDesktop "SetThreadDesktop" sptr
; res = SetThreadDesktop(hDesktop)
; hDesktop : HDESK -> "sptr"; BOOL SetThreadDesktop(HDESK hDesktop)
#uselib "USER32.dll"
#cfunc global SetThreadDesktop "SetThreadDesktop" intptr
; res = SetThreadDesktop(hDesktop)
; hDesktop : HDESK -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
user32 = windows.NewLazySystemDLL("USER32.dll")
procSetThreadDesktop = user32.NewProc("SetThreadDesktop")
)
// hDesktop (HDESK)
r1, _, err := procSetThreadDesktop.Call(
uintptr(hDesktop),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction SetThreadDesktop(
hDesktop: THandle // HDESK
): BOOL; stdcall;
external 'USER32.dll' name 'SetThreadDesktop';result := DllCall("USER32\SetThreadDesktop"
, "Ptr", hDesktop ; HDESK
, "Int") ; return: BOOL●SetThreadDesktop(hDesktop) = DLL("USER32.dll", "bool SetThreadDesktop(void*)")
# 呼び出し: SetThreadDesktop(hDesktop)
# hDesktop : HDESK -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。