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