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

AbortSystemShutdownA

関数
進行中のシステムシャットダウンを中止する。
DLLADVAPI32.dll文字セットANSI (-A)呼出規約winapiSetLastErrorあり対応OSWindows XP 以降

シグネチャ

// ADVAPI32.dll  (ANSI / -A)
#include <windows.h>

BOOL AbortSystemShutdownA(
    LPSTR lpMachineName   // optional
);

パラメーター

名前方向
lpMachineNameLPSTRinoptional

戻り値の型: BOOL

各言語での呼び出し定義

// ADVAPI32.dll  (ANSI / -A)
#include <windows.h>

BOOL AbortSystemShutdownA(
    LPSTR lpMachineName   // optional
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("ADVAPI32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern bool AbortSystemShutdownA(
    [MarshalAs(UnmanagedType.LPStr)] string lpMachineName   // LPSTR optional
);
<DllImport("ADVAPI32.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function AbortSystemShutdownA(
    <MarshalAs(UnmanagedType.LPStr)> lpMachineName As String   ' LPSTR optional
) As Boolean
End Function
' lpMachineName : LPSTR optional
Declare PtrSafe Function AbortSystemShutdownA Lib "advapi32" ( _
    ByVal lpMachineName As String) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

AbortSystemShutdownA = ctypes.windll.advapi32.AbortSystemShutdownA
AbortSystemShutdownA.restype = wintypes.BOOL
AbortSystemShutdownA.argtypes = [
    wintypes.LPCSTR,  # lpMachineName : LPSTR optional
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

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

var (
	advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
	procAbortSystemShutdownA = advapi32.NewProc("AbortSystemShutdownA")
)

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