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