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