GetAclInformation
関数ACLの情報(サイズや改訂など)を取得する。
シグネチャ
// ADVAPI32.dll
#include <windows.h>
BOOL GetAclInformation(
ACL* pAcl,
void* pAclInformation,
DWORD nAclInformationLength,
ACL_INFORMATION_CLASS dwAclInformationClass
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pAcl | ACL* | in | ACL へのポインターです。この関数は、この ACL に関する情報を取得します。null 値が渡された場合、この関数はアクセス違反を引き起こします。 |
| pAclInformation | void* | out | 要求された情報を受け取るバッファーへのポインターです。バッファーに格納される構造体は、dwAclInformationClass パラメーターで要求された情報クラスによって異なります。 |
| nAclInformationLength | DWORD | in | pAclInformation パラメーターが指すバッファーのサイズ (バイト単位) です。 |
| dwAclInformationClass | ACL_INFORMATION_CLASS | in | 要求する情報のクラスを示す ACL_INFORMATION_CLASS 列挙体の値です。このパラメーターには、この列挙体の次の 2 つの値のいずれかを指定できます。
|
戻り値の型: BOOL
公式ドキュメント
アクセス制御リスト (ACL) に関する情報を取得します。
戻り値
関数が成功した場合、0 以外の値を返します。
関数が失敗した場合、0 を返します。拡張エラー情報を取得するには、 GetLastError を呼び出します。
出典・ライセンス: 上記「公式ドキュメント」の内容は 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 GetAclInformation(
ACL* pAcl,
void* pAclInformation,
DWORD nAclInformationLength,
ACL_INFORMATION_CLASS dwAclInformationClass
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("ADVAPI32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool GetAclInformation(
IntPtr pAcl, // ACL*
IntPtr pAclInformation, // void* out
uint nAclInformationLength, // DWORD
int dwAclInformationClass // ACL_INFORMATION_CLASS
);<DllImport("ADVAPI32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GetAclInformation(
pAcl As IntPtr, ' ACL*
pAclInformation As IntPtr, ' void* out
nAclInformationLength As UInteger, ' DWORD
dwAclInformationClass As Integer ' ACL_INFORMATION_CLASS
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' pAcl : ACL*
' pAclInformation : void* out
' nAclInformationLength : DWORD
' dwAclInformationClass : ACL_INFORMATION_CLASS
Declare PtrSafe Function GetAclInformation 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
GetAclInformation = ctypes.windll.advapi32.GetAclInformation
GetAclInformation.restype = wintypes.BOOL
GetAclInformation.argtypes = [
ctypes.c_void_p, # pAcl : ACL*
ctypes.POINTER(None), # pAclInformation : void* out
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')
GetAclInformation = Fiddle::Function.new(
lib['GetAclInformation'],
[
Fiddle::TYPE_VOIDP, # pAcl : ACL*
Fiddle::TYPE_VOIDP, # pAclInformation : void* out
-Fiddle::TYPE_INT, # nAclInformationLength : DWORD
Fiddle::TYPE_INT, # dwAclInformationClass : ACL_INFORMATION_CLASS
],
Fiddle::TYPE_INT)#[link(name = "advapi32")]
extern "system" {
fn GetAclInformation(
pAcl: *mut ACL, // ACL*
pAclInformation: *mut (), // void* out
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 GetAclInformation(IntPtr pAcl, IntPtr pAclInformation, uint nAclInformationLength, int dwAclInformationClass);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVAPI32_GetAclInformation' -Namespace Win32 -PassThru
# $api::GetAclInformation(pAcl, pAclInformation, nAclInformationLength, dwAclInformationClass)#uselib "ADVAPI32.dll"
#func global GetAclInformation "GetAclInformation" sptr, sptr, sptr, sptr
; GetAclInformation varptr(pAcl), pAclInformation, nAclInformationLength, dwAclInformationClass ; 戻り値は stat
; pAcl : ACL* -> "sptr"
; pAclInformation : void* out -> "sptr"
; nAclInformationLength : DWORD -> "sptr"
; dwAclInformationClass : ACL_INFORMATION_CLASS -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "ADVAPI32.dll" #cfunc global GetAclInformation "GetAclInformation" var, sptr, int, int ; res = GetAclInformation(pAcl, pAclInformation, nAclInformationLength, dwAclInformationClass) ; pAcl : ACL* -> "var" ; pAclInformation : void* out -> "sptr" ; nAclInformationLength : DWORD -> "int" ; dwAclInformationClass : ACL_INFORMATION_CLASS -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ADVAPI32.dll" #cfunc global GetAclInformation "GetAclInformation" sptr, sptr, int, int ; res = GetAclInformation(varptr(pAcl), pAclInformation, nAclInformationLength, dwAclInformationClass) ; pAcl : ACL* -> "sptr" ; pAclInformation : void* out -> "sptr" ; nAclInformationLength : DWORD -> "int" ; dwAclInformationClass : ACL_INFORMATION_CLASS -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL GetAclInformation(ACL* pAcl, void* pAclInformation, DWORD nAclInformationLength, ACL_INFORMATION_CLASS dwAclInformationClass) #uselib "ADVAPI32.dll" #cfunc global GetAclInformation "GetAclInformation" var, intptr, int, int ; res = GetAclInformation(pAcl, pAclInformation, nAclInformationLength, dwAclInformationClass) ; pAcl : ACL* -> "var" ; pAclInformation : void* out -> "intptr" ; nAclInformationLength : DWORD -> "int" ; dwAclInformationClass : ACL_INFORMATION_CLASS -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL GetAclInformation(ACL* pAcl, void* pAclInformation, DWORD nAclInformationLength, ACL_INFORMATION_CLASS dwAclInformationClass) #uselib "ADVAPI32.dll" #cfunc global GetAclInformation "GetAclInformation" intptr, intptr, int, int ; res = GetAclInformation(varptr(pAcl), pAclInformation, nAclInformationLength, dwAclInformationClass) ; pAcl : ACL* -> "intptr" ; pAclInformation : void* out -> "intptr" ; nAclInformationLength : DWORD -> "int" ; dwAclInformationClass : ACL_INFORMATION_CLASS -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
procGetAclInformation = advapi32.NewProc("GetAclInformation")
)
// pAcl (ACL*), pAclInformation (void* out), nAclInformationLength (DWORD), dwAclInformationClass (ACL_INFORMATION_CLASS)
r1, _, err := procGetAclInformation.Call(
uintptr(pAcl),
uintptr(pAclInformation),
uintptr(nAclInformationLength),
uintptr(dwAclInformationClass),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction GetAclInformation(
pAcl: Pointer; // ACL*
pAclInformation: Pointer; // void* out
nAclInformationLength: DWORD; // DWORD
dwAclInformationClass: Integer // ACL_INFORMATION_CLASS
): BOOL; stdcall;
external 'ADVAPI32.dll' name 'GetAclInformation';result := DllCall("ADVAPI32\GetAclInformation"
, "Ptr", pAcl ; ACL*
, "Ptr", pAclInformation ; void* out
, "UInt", nAclInformationLength ; DWORD
, "Int", dwAclInformationClass ; ACL_INFORMATION_CLASS
, "Int") ; return: BOOL●GetAclInformation(pAcl, pAclInformation, nAclInformationLength, dwAclInformationClass) = DLL("ADVAPI32.dll", "bool GetAclInformation(void*, void*, dword, int)")
# 呼び出し: GetAclInformation(pAcl, pAclInformation, nAclInformationLength, dwAclInformationClass)
# pAcl : ACL* -> "void*"
# pAclInformation : void* out -> "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 GetAclInformation(
pAcl: [*c]ACL, // ACL*
pAclInformation: ?*anyopaque, // void* out
nAclInformationLength: u32, // DWORD
dwAclInformationClass: i32 // ACL_INFORMATION_CLASS
) callconv(std.os.windows.WINAPI) i32;proc GetAclInformation(
pAcl: ptr ACL, # ACL*
pAclInformation: pointer, # void* out
nAclInformationLength: uint32, # DWORD
dwAclInformationClass: int32 # ACL_INFORMATION_CLASS
): int32 {.importc: "GetAclInformation", stdcall, dynlib: "ADVAPI32.dll".}pragma(lib, "advapi32");
extern(Windows)
int GetAclInformation(
ACL* pAcl, // ACL*
void* pAclInformation, // void* out
uint nAclInformationLength, // DWORD
int dwAclInformationClass // ACL_INFORMATION_CLASS
);ccall((:GetAclInformation, "ADVAPI32.dll"), stdcall, Int32,
(Ptr{ACL}, Ptr{Cvoid}, UInt32, Int32),
pAcl, pAclInformation, nAclInformationLength, dwAclInformationClass)
# pAcl : ACL* -> Ptr{ACL}
# pAclInformation : void* out -> Ptr{Cvoid}
# nAclInformationLength : DWORD -> UInt32
# dwAclInformationClass : ACL_INFORMATION_CLASS -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t GetAclInformation(
void* pAcl,
void* pAclInformation,
uint32_t nAclInformationLength,
int32_t dwAclInformationClass);
]]
local advapi32 = ffi.load("advapi32")
-- advapi32.GetAclInformation(pAcl, pAclInformation, nAclInformationLength, dwAclInformationClass)
-- pAcl : ACL*
-- pAclInformation : void* out
-- nAclInformationLength : DWORD
-- dwAclInformationClass : ACL_INFORMATION_CLASS
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('ADVAPI32.dll');
const GetAclInformation = lib.func('__stdcall', 'GetAclInformation', 'int32_t', ['void *', 'void *', 'uint32_t', 'int32_t']);
// GetAclInformation(pAcl, pAclInformation, nAclInformationLength, dwAclInformationClass)
// pAcl : ACL* -> 'void *'
// pAclInformation : void* out -> 'void *'
// nAclInformationLength : DWORD -> 'uint32_t'
// dwAclInformationClass : ACL_INFORMATION_CLASS -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("ADVAPI32.dll", {
GetAclInformation: { parameters: ["pointer", "pointer", "u32", "i32"], result: "i32" },
});
// lib.symbols.GetAclInformation(pAcl, pAclInformation, nAclInformationLength, dwAclInformationClass)
// pAcl : ACL* -> "pointer"
// pAclInformation : void* out -> "pointer"
// nAclInformationLength : DWORD -> "u32"
// dwAclInformationClass : ACL_INFORMATION_CLASS -> "i32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t GetAclInformation(
void* pAcl,
void* pAclInformation,
uint32_t nAclInformationLength,
int32_t dwAclInformationClass);
C, "ADVAPI32.dll");
// $ffi->GetAclInformation(pAcl, pAclInformation, nAclInformationLength, dwAclInformationClass);
// pAcl : ACL*
// pAclInformation : void* out
// 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 GetAclInformation(
Pointer pAcl, // ACL*
Pointer pAclInformation, // void* out
int nAclInformationLength, // DWORD
int dwAclInformationClass // ACL_INFORMATION_CLASS
);
}@[Link("advapi32")]
lib LibADVAPI32
fun GetAclInformation = GetAclInformation(
pAcl : ACL*, # ACL*
pAclInformation : Void*, # void* out
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 GetAclInformationNative = Int32 Function(Pointer<Void>, Pointer<Void>, Uint32, Int32);
typedef GetAclInformationDart = int Function(Pointer<Void>, Pointer<Void>, int, int);
final GetAclInformation = DynamicLibrary.open('ADVAPI32.dll')
.lookupFunction<GetAclInformationNative, GetAclInformationDart>('GetAclInformation');
// pAcl : ACL* -> Pointer<Void>
// pAclInformation : void* out -> Pointer<Void>
// nAclInformationLength : DWORD -> Uint32
// dwAclInformationClass : ACL_INFORMATION_CLASS -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function GetAclInformation(
pAcl: Pointer; // ACL*
pAclInformation: Pointer; // void* out
nAclInformationLength: DWORD; // DWORD
dwAclInformationClass: Integer // ACL_INFORMATION_CLASS
): BOOL; stdcall;
external 'ADVAPI32.dll' name 'GetAclInformation';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "GetAclInformation"
c_GetAclInformation :: Ptr () -> Ptr () -> Word32 -> Int32 -> IO CInt
-- pAcl : ACL* -> Ptr ()
-- pAclInformation : void* out -> Ptr ()
-- nAclInformationLength : DWORD -> Word32
-- dwAclInformationClass : ACL_INFORMATION_CLASS -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let getaclinformation =
foreign "GetAclInformation"
((ptr void) @-> (ptr void) @-> uint32_t @-> int32_t @-> returning int32_t)
(* pAcl : ACL* -> (ptr void) *)
(* pAclInformation : void* out -> (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 ("GetAclInformation" get-acl-information :convention :stdcall) :int32
(p-acl :pointer) ; ACL*
(p-acl-information :pointer) ; void* out
(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 $GetAclInformation = Win32::API::More->new('ADVAPI32',
'BOOL GetAclInformation(LPVOID pAcl, LPVOID pAclInformation, DWORD nAclInformationLength, int dwAclInformationClass)');
# my $ret = $GetAclInformation->Call($pAcl, $pAclInformation, $nAclInformationLength, $dwAclInformationClass);
# pAcl : ACL* -> LPVOID
# pAclInformation : void* out -> LPVOID
# nAclInformationLength : DWORD -> DWORD
# dwAclInformationClass : ACL_INFORMATION_CLASS -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
公式の関連項目
- s ACL_REVISION_INFORMATION
- s ACL_SIZE_INFORMATION
- f GetAce — ACLから指定インデックスのACEへのポインターを取得する。
- f InitializeAcl — 新しい空のACL構造体を初期化する。
- f IsValidAcl — ACL構造体が有効かどうかを検証する。
- f SetAclInformation — ACLに情報(改訂など)を設定する。