ホーム › System.RemoteDesktop › WTSGetActiveConsoleSessionId
WTSGetActiveConsoleSessionId
関数コンソールにアタッチされたセッションIDを取得する。
シグネチャ
// KERNEL32.dll
#include <windows.h>
DWORD WTSGetActiveConsoleSessionId(void);パラメーターなし。戻り値: DWORD
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
DWORD WTSGetActiveConsoleSessionId(void);[DllImport("KERNEL32.dll", ExactSpelling = true)]
static extern uint WTSGetActiveConsoleSessionId();<DllImport("KERNEL32.dll", ExactSpelling:=True)>
Public Shared Function WTSGetActiveConsoleSessionId() As UInteger
End FunctionDeclare PtrSafe Function WTSGetActiveConsoleSessionId Lib "kernel32" () As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
WTSGetActiveConsoleSessionId = ctypes.windll.kernel32.WTSGetActiveConsoleSessionId
WTSGetActiveConsoleSessionId.restype = wintypes.DWORD
WTSGetActiveConsoleSessionId.argtypes = []require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
WTSGetActiveConsoleSessionId = Fiddle::Function.new(
lib['WTSGetActiveConsoleSessionId'],
[],
-Fiddle::TYPE_INT)#[link(name = "kernel32")]
extern "system" {
fn WTSGetActiveConsoleSessionId() -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("KERNEL32.dll")]
public static extern uint WTSGetActiveConsoleSessionId();
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_WTSGetActiveConsoleSessionId' -Namespace Win32 -PassThru
# $api::WTSGetActiveConsoleSessionId()#uselib "KERNEL32.dll"
#func global WTSGetActiveConsoleSessionId "WTSGetActiveConsoleSessionId"
; WTSGetActiveConsoleSessionId ; 戻り値は stat
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "KERNEL32.dll"
#cfunc global WTSGetActiveConsoleSessionId "WTSGetActiveConsoleSessionId"
; res = WTSGetActiveConsoleSessionId(); DWORD WTSGetActiveConsoleSessionId()
#uselib "KERNEL32.dll"
#cfunc global WTSGetActiveConsoleSessionId "WTSGetActiveConsoleSessionId"
; res = WTSGetActiveConsoleSessionId()import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procWTSGetActiveConsoleSessionId = kernel32.NewProc("WTSGetActiveConsoleSessionId")
)
r1, _, err := procWTSGetActiveConsoleSessionId.Call()
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction WTSGetActiveConsoleSessionId: DWORD; stdcall;
external 'KERNEL32.dll' name 'WTSGetActiveConsoleSessionId';result := DllCall("KERNEL32\WTSGetActiveConsoleSessionId", "UInt")●WTSGetActiveConsoleSessionId() = DLL("KERNEL32.dll", "dword WTSGetActiveConsoleSessionId()")
# 呼び出し: WTSGetActiveConsoleSessionId()
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。