Win32 API 日本語リファレンス
ホームSecurity › DeleteAce

DeleteAce

関数
ACLから指定インデックスのACEを削除する。
DLLADVAPI32.dll呼出規約winapiSetLastErrorあり対応OSWindows XP 以降

シグネチャ

// ADVAPI32.dll
#include <windows.h>

BOOL DeleteAce(
    ACL* pAcl,
    DWORD dwAceIndex
);

パラメーター

名前方向
pAclACL*inout
dwAceIndexDWORDin

戻り値の型: BOOL

各言語での呼び出し定義

// 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 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 方式にも切替可。
出力引数:
; 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 方式にも切替可。
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   // BOOL
function 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)。