DeleteAce
関数ACLから指定インデックスのACEを削除する。
シグネチャ
// ADVAPI32.dll
#include <windows.h>
BOOL DeleteAce(
ACL* pAcl,
DWORD dwAceIndex
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pAcl | ACL* | inout | ACL へのポインターです。dwAceIndex パラメーターで指定された ACE が、この ACL から削除されます。 |
| dwAceIndex | DWORD | in | 削除する ACE です。値 0 は ACL 内の最初の ACE に、値 1 は 2 番目の ACE に対応し、以降同様です。 |
戻り値の型: BOOL
公式ドキュメント
アクセス制御リスト (ACL) からアクセス制御エントリ (ACE) を削除します。
戻り値
関数が成功した場合、関数は 0 以外の値を返します。
関数が失敗した場合、戻り値は 0 です。拡張エラー情報を取得するには、 GetLastError を呼び出します。
解説(Remarks)
アプリケーションは、 GetAclInformation 関数によって取得した ACL_SIZE_INFORMATION 構造体を使用して、ACL のサイズと、それが含む ACE の数を調べることができます。 GetAce 関数は、個々の ACE に関する情報を取得します。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// ADVAPI32.dll
#include <windows.h>
BOOL DeleteAce(
ACL* pAcl,
DWORD dwAceIndex
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("ADVAPI32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool DeleteAce(
IntPtr pAcl, // ACL* in/out
uint dwAceIndex // DWORD
);<DllImport("ADVAPI32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function DeleteAce(
pAcl As IntPtr, ' ACL* in/out
dwAceIndex As UInteger ' DWORD
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' pAcl : ACL* in/out
' dwAceIndex : DWORD
Declare PtrSafe Function DeleteAce Lib "advapi32" ( _
ByVal pAcl As LongPtr, _
ByVal dwAceIndex As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
DeleteAce = ctypes.windll.advapi32.DeleteAce
DeleteAce.restype = wintypes.BOOL
DeleteAce.argtypes = [
ctypes.c_void_p, # pAcl : ACL* in/out
wintypes.DWORD, # dwAceIndex : DWORD
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ADVAPI32.dll')
DeleteAce = Fiddle::Function.new(
lib['DeleteAce'],
[
Fiddle::TYPE_VOIDP, # pAcl : ACL* in/out
-Fiddle::TYPE_INT, # dwAceIndex : DWORD
],
Fiddle::TYPE_INT)#[link(name = "advapi32")]
extern "system" {
fn DeleteAce(
pAcl: *mut ACL, // ACL* in/out
dwAceIndex: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("ADVAPI32.dll", SetLastError = true)]
public static extern bool DeleteAce(IntPtr pAcl, uint dwAceIndex);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVAPI32_DeleteAce' -Namespace Win32 -PassThru
# $api::DeleteAce(pAcl, dwAceIndex)#uselib "ADVAPI32.dll"
#func global DeleteAce "DeleteAce" sptr, sptr
; DeleteAce varptr(pAcl), dwAceIndex ; 戻り値は stat
; pAcl : ACL* in/out -> "sptr"
; dwAceIndex : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "ADVAPI32.dll" #cfunc global DeleteAce "DeleteAce" var, int ; res = DeleteAce(pAcl, dwAceIndex) ; pAcl : ACL* in/out -> "var" ; dwAceIndex : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ADVAPI32.dll" #cfunc global DeleteAce "DeleteAce" sptr, int ; res = DeleteAce(varptr(pAcl), dwAceIndex) ; pAcl : ACL* in/out -> "sptr" ; dwAceIndex : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL DeleteAce(ACL* pAcl, DWORD dwAceIndex) #uselib "ADVAPI32.dll" #cfunc global DeleteAce "DeleteAce" var, int ; res = DeleteAce(pAcl, dwAceIndex) ; pAcl : ACL* in/out -> "var" ; dwAceIndex : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL DeleteAce(ACL* pAcl, DWORD dwAceIndex) #uselib "ADVAPI32.dll" #cfunc global DeleteAce "DeleteAce" intptr, int ; res = DeleteAce(varptr(pAcl), dwAceIndex) ; pAcl : ACL* in/out -> "intptr" ; dwAceIndex : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
procDeleteAce = advapi32.NewProc("DeleteAce")
)
// pAcl (ACL* in/out), dwAceIndex (DWORD)
r1, _, err := procDeleteAce.Call(
uintptr(pAcl),
uintptr(dwAceIndex),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction DeleteAce(
pAcl: Pointer; // ACL* in/out
dwAceIndex: DWORD // DWORD
): BOOL; stdcall;
external 'ADVAPI32.dll' name 'DeleteAce';result := DllCall("ADVAPI32\DeleteAce"
, "Ptr", pAcl ; ACL* in/out
, "UInt", dwAceIndex ; DWORD
, "Int") ; return: BOOL●DeleteAce(pAcl, dwAceIndex) = DLL("ADVAPI32.dll", "bool DeleteAce(void*, dword)")
# 呼び出し: DeleteAce(pAcl, dwAceIndex)
# pAcl : ACL* in/out -> "void*"
# dwAceIndex : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "advapi32" fn DeleteAce(
pAcl: [*c]ACL, // ACL* in/out
dwAceIndex: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;proc DeleteAce(
pAcl: ptr ACL, # ACL* in/out
dwAceIndex: uint32 # DWORD
): int32 {.importc: "DeleteAce", stdcall, dynlib: "ADVAPI32.dll".}pragma(lib, "advapi32");
extern(Windows)
int DeleteAce(
ACL* pAcl, // ACL* in/out
uint dwAceIndex // DWORD
);ccall((:DeleteAce, "ADVAPI32.dll"), stdcall, Int32,
(Ptr{ACL}, UInt32),
pAcl, dwAceIndex)
# pAcl : ACL* in/out -> Ptr{ACL}
# dwAceIndex : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t DeleteAce(
void* pAcl,
uint32_t dwAceIndex);
]]
local advapi32 = ffi.load("advapi32")
-- advapi32.DeleteAce(pAcl, dwAceIndex)
-- pAcl : ACL* in/out
-- dwAceIndex : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('ADVAPI32.dll');
const DeleteAce = lib.func('__stdcall', 'DeleteAce', 'int32_t', ['void *', 'uint32_t']);
// DeleteAce(pAcl, dwAceIndex)
// pAcl : ACL* in/out -> 'void *'
// dwAceIndex : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("ADVAPI32.dll", {
DeleteAce: { parameters: ["pointer", "u32"], result: "i32" },
});
// lib.symbols.DeleteAce(pAcl, dwAceIndex)
// pAcl : ACL* in/out -> "pointer"
// dwAceIndex : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t DeleteAce(
void* pAcl,
uint32_t dwAceIndex);
C, "ADVAPI32.dll");
// $ffi->DeleteAce(pAcl, dwAceIndex);
// pAcl : ACL* in/out
// dwAceIndex : DWORD
// 構造体/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);
boolean DeleteAce(
Pointer pAcl, // ACL* in/out
int dwAceIndex // DWORD
);
}@[Link("advapi32")]
lib LibADVAPI32
fun DeleteAce = DeleteAce(
pAcl : ACL*, # ACL* in/out
dwAceIndex : UInt32 # DWORD
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef DeleteAceNative = Int32 Function(Pointer<Void>, Uint32);
typedef DeleteAceDart = int Function(Pointer<Void>, int);
final DeleteAce = DynamicLibrary.open('ADVAPI32.dll')
.lookupFunction<DeleteAceNative, DeleteAceDart>('DeleteAce');
// pAcl : ACL* in/out -> Pointer<Void>
// dwAceIndex : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function DeleteAce(
pAcl: Pointer; // ACL* in/out
dwAceIndex: DWORD // DWORD
): BOOL; stdcall;
external 'ADVAPI32.dll' name 'DeleteAce';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "DeleteAce"
c_DeleteAce :: Ptr () -> Word32 -> IO CInt
-- pAcl : ACL* in/out -> Ptr ()
-- dwAceIndex : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let deleteace =
foreign "DeleteAce"
((ptr void) @-> uint32_t @-> returning int32_t)
(* pAcl : ACL* in/out -> (ptr void) *)
(* dwAceIndex : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library advapi32 (t "ADVAPI32.dll"))
(cffi:use-foreign-library advapi32)
(cffi:defcfun ("DeleteAce" delete-ace :convention :stdcall) :int32
(p-acl :pointer) ; ACL* in/out
(dw-ace-index :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $DeleteAce = Win32::API::More->new('ADVAPI32',
'BOOL DeleteAce(LPVOID pAcl, DWORD dwAceIndex)');
# my $ret = $DeleteAce->Call($pAcl, $dwAceIndex);
# pAcl : ACL* in/out -> LPVOID
# dwAceIndex : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
公式の関連項目
- s ACL_SIZE_INFORMATION
- f AddAccessAllowedAce — ACLにアクセス許可ACEを追加する。
- f AddAccessDeniedAce — ACLにアクセス拒否ACEを追加する。
- f AddAce — ACLの指定位置に1つ以上のACEを追加する。
- f AddAuditAccessAce — ACL(SACL)に監査用ACEを追加する。
- f GetAce — ACLから指定インデックスのACEへのポインターを取得する。
- f GetAclInformation — ACLの情報(サイズや改訂など)を取得する。
使用する型