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