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

SetAclInformation

関数
ACLに情報(改訂など)を設定する。
DLLADVAPI32.dll呼出規約winapiSetLastErrorあり対応OSWindows XP 以降

シグネチャ

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

BOOL SetAclInformation(
    ACL* pAcl,
    void* pAclInformation,
    DWORD nAclInformationLength,
    ACL_INFORMATION_CLASS dwAclInformationClass
);

パラメーター

名前方向説明
pAclACL*inoutACL へのポインター。この関数は、この ACL に情報を設定します。
pAclInformationvoid*in設定する情報を格納したバッファーへのポインター。これは ACL_REVISION_INFORMATION 構造体へのポインターである必要があります。
nAclInformationLengthDWORDinpAclInfo パラメーターが指すバッファーのサイズ (バイト単位)。
dwAclInformationClassACL_INFORMATION_CLASSin

要求する情報のクラスを指定する ACL_INFORMATION_CLASS 列挙型。

現在、このパラメーターには AclRevisionInformation を指定できます。これは、pAclInformation パラメーターが指すバッファーに ACL_REVISION_INFORMATION 構造体が格納されていることを意味します。

戻り値の型: BOOL

公式ドキュメント

アクセス制御リスト (ACL) に関する情報を設定します。

戻り値

関数が成功した場合、0 以外の値を返します。

関数が失敗した場合は 0 を返します。拡張エラー情報を取得するには、GetLastError を呼び出します。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

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

BOOL SetAclInformation(
    ACL* pAcl,
    void* pAclInformation,
    DWORD nAclInformationLength,
    ACL_INFORMATION_CLASS dwAclInformationClass
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("ADVAPI32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool SetAclInformation(
    IntPtr pAcl,   // ACL* in/out
    IntPtr pAclInformation,   // void*
    uint nAclInformationLength,   // DWORD
    int dwAclInformationClass   // ACL_INFORMATION_CLASS
);
<DllImport("ADVAPI32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetAclInformation(
    pAcl As IntPtr,   ' ACL* in/out
    pAclInformation As IntPtr,   ' void*
    nAclInformationLength As UInteger,   ' DWORD
    dwAclInformationClass As Integer   ' ACL_INFORMATION_CLASS
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
' pAcl : ACL* in/out
' pAclInformation : void*
' nAclInformationLength : DWORD
' dwAclInformationClass : ACL_INFORMATION_CLASS
Declare PtrSafe Function SetAclInformation Lib "advapi32" ( _
    ByVal pAcl As LongPtr, _
    ByVal pAclInformation As LongPtr, _
    ByVal nAclInformationLength As Long, _
    ByVal dwAclInformationClass As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SetAclInformation = ctypes.windll.advapi32.SetAclInformation
SetAclInformation.restype = wintypes.BOOL
SetAclInformation.argtypes = [
    ctypes.c_void_p,  # pAcl : ACL* in/out
    ctypes.POINTER(None),  # pAclInformation : void*
    wintypes.DWORD,  # nAclInformationLength : DWORD
    ctypes.c_int,  # dwAclInformationClass : ACL_INFORMATION_CLASS
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('ADVAPI32.dll')
SetAclInformation = Fiddle::Function.new(
  lib['SetAclInformation'],
  [
    Fiddle::TYPE_VOIDP,  # pAcl : ACL* in/out
    Fiddle::TYPE_VOIDP,  # pAclInformation : void*
    -Fiddle::TYPE_INT,  # nAclInformationLength : DWORD
    Fiddle::TYPE_INT,  # dwAclInformationClass : ACL_INFORMATION_CLASS
  ],
  Fiddle::TYPE_INT)
#[link(name = "advapi32")]
extern "system" {
    fn SetAclInformation(
        pAcl: *mut ACL,  // ACL* in/out
        pAclInformation: *mut (),  // void*
        nAclInformationLength: u32,  // DWORD
        dwAclInformationClass: i32  // ACL_INFORMATION_CLASS
    ) -> 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 SetAclInformation(IntPtr pAcl, IntPtr pAclInformation, uint nAclInformationLength, int dwAclInformationClass);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVAPI32_SetAclInformation' -Namespace Win32 -PassThru
# $api::SetAclInformation(pAcl, pAclInformation, nAclInformationLength, dwAclInformationClass)
#uselib "ADVAPI32.dll"
#func global SetAclInformation "SetAclInformation" sptr, sptr, sptr, sptr
; SetAclInformation varptr(pAcl), pAclInformation, nAclInformationLength, dwAclInformationClass   ; 戻り値は stat
; pAcl : ACL* in/out -> "sptr"
; pAclInformation : void* -> "sptr"
; nAclInformationLength : DWORD -> "sptr"
; dwAclInformationClass : ACL_INFORMATION_CLASS -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "ADVAPI32.dll"
#cfunc global SetAclInformation "SetAclInformation" var, sptr, int, int
; res = SetAclInformation(pAcl, pAclInformation, nAclInformationLength, dwAclInformationClass)
; pAcl : ACL* in/out -> "var"
; pAclInformation : void* -> "sptr"
; nAclInformationLength : DWORD -> "int"
; dwAclInformationClass : ACL_INFORMATION_CLASS -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL SetAclInformation(ACL* pAcl, void* pAclInformation, DWORD nAclInformationLength, ACL_INFORMATION_CLASS dwAclInformationClass)
#uselib "ADVAPI32.dll"
#cfunc global SetAclInformation "SetAclInformation" var, intptr, int, int
; res = SetAclInformation(pAcl, pAclInformation, nAclInformationLength, dwAclInformationClass)
; pAcl : ACL* in/out -> "var"
; pAclInformation : void* -> "intptr"
; nAclInformationLength : DWORD -> "int"
; dwAclInformationClass : ACL_INFORMATION_CLASS -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
	procSetAclInformation = advapi32.NewProc("SetAclInformation")
)

// pAcl (ACL* in/out), pAclInformation (void*), nAclInformationLength (DWORD), dwAclInformationClass (ACL_INFORMATION_CLASS)
r1, _, err := procSetAclInformation.Call(
	uintptr(pAcl),
	uintptr(pAclInformation),
	uintptr(nAclInformationLength),
	uintptr(dwAclInformationClass),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function SetAclInformation(
  pAcl: Pointer;   // ACL* in/out
  pAclInformation: Pointer;   // void*
  nAclInformationLength: DWORD;   // DWORD
  dwAclInformationClass: Integer   // ACL_INFORMATION_CLASS
): BOOL; stdcall;
  external 'ADVAPI32.dll' name 'SetAclInformation';
result := DllCall("ADVAPI32\SetAclInformation"
    , "Ptr", pAcl   ; ACL* in/out
    , "Ptr", pAclInformation   ; void*
    , "UInt", nAclInformationLength   ; DWORD
    , "Int", dwAclInformationClass   ; ACL_INFORMATION_CLASS
    , "Int")   ; return: BOOL
●SetAclInformation(pAcl, pAclInformation, nAclInformationLength, dwAclInformationClass) = DLL("ADVAPI32.dll", "bool SetAclInformation(void*, void*, dword, int)")
# 呼び出し: SetAclInformation(pAcl, pAclInformation, nAclInformationLength, dwAclInformationClass)
# pAcl : ACL* in/out -> "void*"
# pAclInformation : void* -> "void*"
# nAclInformationLength : DWORD -> "dword"
# dwAclInformationClass : ACL_INFORMATION_CLASS -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "advapi32" fn SetAclInformation(
    pAcl: [*c]ACL, // ACL* in/out
    pAclInformation: ?*anyopaque, // void*
    nAclInformationLength: u32, // DWORD
    dwAclInformationClass: i32 // ACL_INFORMATION_CLASS
) callconv(std.os.windows.WINAPI) i32;
proc SetAclInformation(
    pAcl: ptr ACL,  # ACL* in/out
    pAclInformation: pointer,  # void*
    nAclInformationLength: uint32,  # DWORD
    dwAclInformationClass: int32  # ACL_INFORMATION_CLASS
): int32 {.importc: "SetAclInformation", stdcall, dynlib: "ADVAPI32.dll".}
pragma(lib, "advapi32");
extern(Windows)
int SetAclInformation(
    ACL* pAcl,   // ACL* in/out
    void* pAclInformation,   // void*
    uint nAclInformationLength,   // DWORD
    int dwAclInformationClass   // ACL_INFORMATION_CLASS
);
ccall((:SetAclInformation, "ADVAPI32.dll"), stdcall, Int32,
      (Ptr{ACL}, Ptr{Cvoid}, UInt32, Int32),
      pAcl, pAclInformation, nAclInformationLength, dwAclInformationClass)
# pAcl : ACL* in/out -> Ptr{ACL}
# pAclInformation : void* -> Ptr{Cvoid}
# nAclInformationLength : DWORD -> UInt32
# dwAclInformationClass : ACL_INFORMATION_CLASS -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t SetAclInformation(
    void* pAcl,
    void* pAclInformation,
    uint32_t nAclInformationLength,
    int32_t dwAclInformationClass);
]]
local advapi32 = ffi.load("advapi32")
-- advapi32.SetAclInformation(pAcl, pAclInformation, nAclInformationLength, dwAclInformationClass)
-- pAcl : ACL* in/out
-- pAclInformation : void*
-- nAclInformationLength : DWORD
-- dwAclInformationClass : ACL_INFORMATION_CLASS
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('ADVAPI32.dll');
const SetAclInformation = lib.func('__stdcall', 'SetAclInformation', 'int32_t', ['void *', 'void *', 'uint32_t', 'int32_t']);
// SetAclInformation(pAcl, pAclInformation, nAclInformationLength, dwAclInformationClass)
// pAcl : ACL* in/out -> 'void *'
// pAclInformation : void* -> 'void *'
// nAclInformationLength : DWORD -> 'uint32_t'
// dwAclInformationClass : ACL_INFORMATION_CLASS -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("ADVAPI32.dll", {
  SetAclInformation: { parameters: ["pointer", "pointer", "u32", "i32"], result: "i32" },
});
// lib.symbols.SetAclInformation(pAcl, pAclInformation, nAclInformationLength, dwAclInformationClass)
// pAcl : ACL* in/out -> "pointer"
// pAclInformation : void* -> "pointer"
// nAclInformationLength : DWORD -> "u32"
// dwAclInformationClass : ACL_INFORMATION_CLASS -> "i32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t SetAclInformation(
    void* pAcl,
    void* pAclInformation,
    uint32_t nAclInformationLength,
    int32_t dwAclInformationClass);
C, "ADVAPI32.dll");
// $ffi->SetAclInformation(pAcl, pAclInformation, nAclInformationLength, dwAclInformationClass);
// pAcl : ACL* in/out
// pAclInformation : void*
// nAclInformationLength : DWORD
// dwAclInformationClass : ACL_INFORMATION_CLASS
// 構造体/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 SetAclInformation(
        Pointer pAcl,   // ACL* in/out
        Pointer pAclInformation,   // void*
        int nAclInformationLength,   // DWORD
        int dwAclInformationClass   // ACL_INFORMATION_CLASS
    );
}
@[Link("advapi32")]
lib LibADVAPI32
  fun SetAclInformation = SetAclInformation(
    pAcl : ACL*,   # ACL* in/out
    pAclInformation : Void*,   # void*
    nAclInformationLength : UInt32,   # DWORD
    dwAclInformationClass : Int32   # ACL_INFORMATION_CLASS
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef SetAclInformationNative = Int32 Function(Pointer<Void>, Pointer<Void>, Uint32, Int32);
typedef SetAclInformationDart = int Function(Pointer<Void>, Pointer<Void>, int, int);
final SetAclInformation = DynamicLibrary.open('ADVAPI32.dll')
    .lookupFunction<SetAclInformationNative, SetAclInformationDart>('SetAclInformation');
// pAcl : ACL* in/out -> Pointer<Void>
// pAclInformation : void* -> Pointer<Void>
// nAclInformationLength : DWORD -> Uint32
// dwAclInformationClass : ACL_INFORMATION_CLASS -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function SetAclInformation(
  pAcl: Pointer;   // ACL* in/out
  pAclInformation: Pointer;   // void*
  nAclInformationLength: DWORD;   // DWORD
  dwAclInformationClass: Integer   // ACL_INFORMATION_CLASS
): BOOL; stdcall;
  external 'ADVAPI32.dll' name 'SetAclInformation';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "SetAclInformation"
  c_SetAclInformation :: Ptr () -> Ptr () -> Word32 -> Int32 -> IO CInt
-- pAcl : ACL* in/out -> Ptr ()
-- pAclInformation : void* -> Ptr ()
-- nAclInformationLength : DWORD -> Word32
-- dwAclInformationClass : ACL_INFORMATION_CLASS -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let setaclinformation =
  foreign "SetAclInformation"
    ((ptr void) @-> (ptr void) @-> uint32_t @-> int32_t @-> returning int32_t)
(* pAcl : ACL* in/out -> (ptr void) *)
(* pAclInformation : void* -> (ptr void) *)
(* nAclInformationLength : DWORD -> uint32_t *)
(* dwAclInformationClass : ACL_INFORMATION_CLASS -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library advapi32 (t "ADVAPI32.dll"))
(cffi:use-foreign-library advapi32)

(cffi:defcfun ("SetAclInformation" set-acl-information :convention :stdcall) :int32
  (p-acl :pointer)   ; ACL* in/out
  (p-acl-information :pointer)   ; void*
  (n-acl-information-length :uint32)   ; DWORD
  (dw-acl-information-class :int32))   ; ACL_INFORMATION_CLASS
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $SetAclInformation = Win32::API::More->new('ADVAPI32',
    'BOOL SetAclInformation(LPVOID pAcl, LPVOID pAclInformation, DWORD nAclInformationLength, int dwAclInformationClass)');
# my $ret = $SetAclInformation->Call($pAcl, $pAclInformation, $nAclInformationLength, $dwAclInformationClass);
# pAcl : ACL* in/out -> LPVOID
# pAclInformation : void* -> LPVOID
# nAclInformationLength : DWORD -> DWORD
# dwAclInformationClass : ACL_INFORMATION_CLASS -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

公式の関連項目
使用する型