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

WTSVirtualChannelClose

関数
開いた仮想チャネルのハンドルを閉じる。
DLLWTSAPI32.dll呼出規約winapiSetLastErrorあり対応OSWindows Vista 以降

シグネチャ

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

BOOL WTSVirtualChannelClose(
    HANDLE hChannelHandle
);

パラメーター

名前方向
hChannelHandleHANDLEin

戻り値の型: BOOL

各言語での呼び出し定義

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

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

WTSVirtualChannelClose = ctypes.windll.wtsapi32.WTSVirtualChannelClose
WTSVirtualChannelClose.restype = wintypes.BOOL
WTSVirtualChannelClose.argtypes = [
    wintypes.HANDLE,  # hChannelHandle : HANDLE
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WTSAPI32.dll')
WTSVirtualChannelClose = Fiddle::Function.new(
  lib['WTSVirtualChannelClose'],
  [
    Fiddle::TYPE_VOIDP,  # hChannelHandle : HANDLE
  ],
  Fiddle::TYPE_INT)
#[link(name = "wtsapi32")]
extern "system" {
    fn WTSVirtualChannelClose(
        hChannelHandle: *mut core::ffi::c_void  // HANDLE
    ) -> 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 WTSVirtualChannelClose(IntPtr hChannelHandle);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WTSAPI32_WTSVirtualChannelClose' -Namespace Win32 -PassThru
# $api::WTSVirtualChannelClose(hChannelHandle)
#uselib "WTSAPI32.dll"
#func global WTSVirtualChannelClose "WTSVirtualChannelClose" sptr
; WTSVirtualChannelClose hChannelHandle   ; 戻り値は stat
; hChannelHandle : HANDLE -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "WTSAPI32.dll"
#cfunc global WTSVirtualChannelClose "WTSVirtualChannelClose" sptr
; res = WTSVirtualChannelClose(hChannelHandle)
; hChannelHandle : HANDLE -> "sptr"
; BOOL WTSVirtualChannelClose(HANDLE hChannelHandle)
#uselib "WTSAPI32.dll"
#cfunc global WTSVirtualChannelClose "WTSVirtualChannelClose" intptr
; res = WTSVirtualChannelClose(hChannelHandle)
; hChannelHandle : HANDLE -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wtsapi32 = windows.NewLazySystemDLL("WTSAPI32.dll")
	procWTSVirtualChannelClose = wtsapi32.NewProc("WTSVirtualChannelClose")
)

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