ホーム › System.Shutdown › AbortSystemShutdownA
AbortSystemShutdownA
関数進行中のシステムシャットダウンを中止する。
シグネチャ
// ADVAPI32.dll (ANSI / -A)
#include <windows.h>
BOOL AbortSystemShutdownA(
LPSTR lpMachineName // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| lpMachineName | LPSTR | inoptional | シャットダウンを中止する対象コンピュータ名。NULLでローカルマシン。 |
戻り値の型: 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 <MarshalAs(UnmanagedType.Bool)> 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 // BOOLfunction 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)。const std = @import("std");
extern "advapi32" fn AbortSystemShutdownA(
lpMachineName: [*c]const u8 // LPSTR optional
) callconv(std.os.windows.WINAPI) i32;proc AbortSystemShutdownA(
lpMachineName: cstring # LPSTR optional
): int32 {.importc: "AbortSystemShutdownA", stdcall, dynlib: "ADVAPI32.dll".}pragma(lib, "advapi32");
extern(Windows)
int AbortSystemShutdownA(
const(char)* lpMachineName // LPSTR optional
);ccall((:AbortSystemShutdownA, "ADVAPI32.dll"), stdcall, Int32,
(Cstring,),
lpMachineName)
# lpMachineName : LPSTR optional -> Cstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t AbortSystemShutdownA(
const char* lpMachineName);
]]
local advapi32 = ffi.load("advapi32")
-- advapi32.AbortSystemShutdownA(lpMachineName)
-- lpMachineName : LPSTR optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('ADVAPI32.dll');
const AbortSystemShutdownA = lib.func('__stdcall', 'AbortSystemShutdownA', 'int32_t', ['str']);
// AbortSystemShutdownA(lpMachineName)
// lpMachineName : LPSTR optional -> 'str'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("ADVAPI32.dll", {
AbortSystemShutdownA: { parameters: ["buffer"], result: "i32" },
});
// lib.symbols.AbortSystemShutdownA(lpMachineName)
// lpMachineName : LPSTR optional -> "buffer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t AbortSystemShutdownA(
const char* lpMachineName);
C, "ADVAPI32.dll");
// $ffi->AbortSystemShutdownA(lpMachineName);
// lpMachineName : LPSTR optional
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Advapi32 extends StdCallLibrary {
Advapi32 INSTANCE = Native.load("advapi32", Advapi32.class, W32APIOptions.ASCII_OPTIONS);
boolean AbortSystemShutdownA(
String lpMachineName // LPSTR optional
);
}@[Link("advapi32")]
lib LibADVAPI32
fun AbortSystemShutdownA = AbortSystemShutdownA(
lpMachineName : UInt8* # LPSTR optional
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef AbortSystemShutdownANative = Int32 Function(Pointer<Utf8>);
typedef AbortSystemShutdownADart = int Function(Pointer<Utf8>);
final AbortSystemShutdownA = DynamicLibrary.open('ADVAPI32.dll')
.lookupFunction<AbortSystemShutdownANative, AbortSystemShutdownADart>('AbortSystemShutdownA');
// lpMachineName : LPSTR optional -> Pointer<Utf8>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function AbortSystemShutdownA(
lpMachineName: PAnsiChar // LPSTR optional
): BOOL; stdcall;
external 'ADVAPI32.dll' name 'AbortSystemShutdownA';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "AbortSystemShutdownA"
c_AbortSystemShutdownA :: CString -> IO CInt
-- lpMachineName : LPSTR optional -> CString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let abortsystemshutdowna =
foreign "AbortSystemShutdownA"
(string @-> returning int32_t)
(* lpMachineName : LPSTR optional -> string *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library advapi32 (t "ADVAPI32.dll"))
(cffi:use-foreign-library advapi32)
(cffi:defcfun ("AbortSystemShutdownA" abort-system-shutdown-a :convention :stdcall) :int32
(lp-machine-name :string)) ; LPSTR optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $AbortSystemShutdownA = Win32::API::More->new('ADVAPI32',
'BOOL AbortSystemShutdownA(LPCSTR lpMachineName)');
# my $ret = $AbortSystemShutdownA->Call($lpMachineName);
# lpMachineName : LPSTR optional -> LPCSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
文字セット違い
- f AbortSystemShutdownW (Unicode版) — 進行中のシステムシャットダウンを中止する。