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

WTSActiveSessionExists

関数
アクティブなセッションが存在するか判定する。
DLLWTSAPI32.dll呼出規約winapi

シグネチャ

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

BOOL WTSActiveSessionExists(
    BOOL* pbActiveSessionExists
);

パラメーター

名前方向
pbActiveSessionExistsBOOL*out

戻り値の型: BOOL

各言語での呼び出し定義

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

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

WTSActiveSessionExists = ctypes.windll.wtsapi32.WTSActiveSessionExists
WTSActiveSessionExists.restype = wintypes.BOOL
WTSActiveSessionExists.argtypes = [
    ctypes.c_void_p,  # pbActiveSessionExists : BOOL* out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	wtsapi32 = windows.NewLazySystemDLL("WTSAPI32.dll")
	procWTSActiveSessionExists = wtsapi32.NewProc("WTSActiveSessionExists")
)

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