ホーム › Security.Authorization › SetEntriesInAclW
SetEntriesInAclW
関数明示的アクセスエントリのリストから新しいACLを作成する(Unicode版)。
シグネチャ
// ADVAPI32.dll (Unicode / -W)
#include <windows.h>
WIN32_ERROR SetEntriesInAclW(
DWORD cCountOfExplicitEntries,
EXPLICIT_ACCESS_W* pListOfExplicitEntries, // optional
ACL* OldAcl, // optional
ACL** NewAcl
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| cCountOfExplicitEntries | DWORD | in |
| pListOfExplicitEntries | EXPLICIT_ACCESS_W* | inoptional |
| OldAcl | ACL* | inoptional |
| NewAcl | ACL** | out |
戻り値の型: WIN32_ERROR
各言語での呼び出し定義
// ADVAPI32.dll (Unicode / -W)
#include <windows.h>
WIN32_ERROR SetEntriesInAclW(
DWORD cCountOfExplicitEntries,
EXPLICIT_ACCESS_W* pListOfExplicitEntries, // optional
ACL* OldAcl, // optional
ACL** NewAcl
);[DllImport("ADVAPI32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint SetEntriesInAclW(
uint cCountOfExplicitEntries, // DWORD
IntPtr pListOfExplicitEntries, // EXPLICIT_ACCESS_W* optional
IntPtr OldAcl, // ACL* optional
IntPtr NewAcl // ACL** out
);<DllImport("ADVAPI32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function SetEntriesInAclW(
cCountOfExplicitEntries As UInteger, ' DWORD
pListOfExplicitEntries As IntPtr, ' EXPLICIT_ACCESS_W* optional
OldAcl As IntPtr, ' ACL* optional
NewAcl As IntPtr ' ACL** out
) As UInteger
End Function' cCountOfExplicitEntries : DWORD
' pListOfExplicitEntries : EXPLICIT_ACCESS_W* optional
' OldAcl : ACL* optional
' NewAcl : ACL** out
Declare PtrSafe Function SetEntriesInAclW Lib "advapi32" ( _
ByVal cCountOfExplicitEntries As Long, _
ByVal pListOfExplicitEntries As LongPtr, _
ByVal OldAcl As LongPtr, _
ByVal NewAcl As LongPtr) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SetEntriesInAclW = ctypes.windll.advapi32.SetEntriesInAclW
SetEntriesInAclW.restype = wintypes.DWORD
SetEntriesInAclW.argtypes = [
wintypes.DWORD, # cCountOfExplicitEntries : DWORD
ctypes.c_void_p, # pListOfExplicitEntries : EXPLICIT_ACCESS_W* optional
ctypes.c_void_p, # OldAcl : ACL* optional
ctypes.c_void_p, # NewAcl : ACL** out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ADVAPI32.dll')
SetEntriesInAclW = Fiddle::Function.new(
lib['SetEntriesInAclW'],
[
-Fiddle::TYPE_INT, # cCountOfExplicitEntries : DWORD
Fiddle::TYPE_VOIDP, # pListOfExplicitEntries : EXPLICIT_ACCESS_W* optional
Fiddle::TYPE_VOIDP, # OldAcl : ACL* optional
Fiddle::TYPE_VOIDP, # NewAcl : ACL** out
],
-Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "advapi32")]
extern "system" {
fn SetEntriesInAclW(
cCountOfExplicitEntries: u32, // DWORD
pListOfExplicitEntries: *mut EXPLICIT_ACCESS_W, // EXPLICIT_ACCESS_W* optional
OldAcl: *mut ACL, // ACL* optional
NewAcl: *mut *mut ACL // ACL** out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ADVAPI32.dll", CharSet = CharSet.Unicode)]
public static extern uint SetEntriesInAclW(uint cCountOfExplicitEntries, IntPtr pListOfExplicitEntries, IntPtr OldAcl, IntPtr NewAcl);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVAPI32_SetEntriesInAclW' -Namespace Win32 -PassThru
# $api::SetEntriesInAclW(cCountOfExplicitEntries, pListOfExplicitEntries, OldAcl, NewAcl)#uselib "ADVAPI32.dll"
#func global SetEntriesInAclW "SetEntriesInAclW" wptr, wptr, wptr, wptr
; SetEntriesInAclW cCountOfExplicitEntries, varptr(pListOfExplicitEntries), varptr(OldAcl), varptr(NewAcl) ; 戻り値は stat
; cCountOfExplicitEntries : DWORD -> "wptr"
; pListOfExplicitEntries : EXPLICIT_ACCESS_W* optional -> "wptr"
; OldAcl : ACL* optional -> "wptr"
; NewAcl : ACL** out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "ADVAPI32.dll" #cfunc global SetEntriesInAclW "SetEntriesInAclW" int, var, var, var ; res = SetEntriesInAclW(cCountOfExplicitEntries, pListOfExplicitEntries, OldAcl, NewAcl) ; cCountOfExplicitEntries : DWORD -> "int" ; pListOfExplicitEntries : EXPLICIT_ACCESS_W* optional -> "var" ; OldAcl : ACL* optional -> "var" ; NewAcl : ACL** out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ADVAPI32.dll" #cfunc global SetEntriesInAclW "SetEntriesInAclW" int, sptr, sptr, sptr ; res = SetEntriesInAclW(cCountOfExplicitEntries, varptr(pListOfExplicitEntries), varptr(OldAcl), varptr(NewAcl)) ; cCountOfExplicitEntries : DWORD -> "int" ; pListOfExplicitEntries : EXPLICIT_ACCESS_W* optional -> "sptr" ; OldAcl : ACL* optional -> "sptr" ; NewAcl : ACL** out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; WIN32_ERROR SetEntriesInAclW(DWORD cCountOfExplicitEntries, EXPLICIT_ACCESS_W* pListOfExplicitEntries, ACL* OldAcl, ACL** NewAcl) #uselib "ADVAPI32.dll" #cfunc global SetEntriesInAclW "SetEntriesInAclW" int, var, var, var ; res = SetEntriesInAclW(cCountOfExplicitEntries, pListOfExplicitEntries, OldAcl, NewAcl) ; cCountOfExplicitEntries : DWORD -> "int" ; pListOfExplicitEntries : EXPLICIT_ACCESS_W* optional -> "var" ; OldAcl : ACL* optional -> "var" ; NewAcl : ACL** out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; WIN32_ERROR SetEntriesInAclW(DWORD cCountOfExplicitEntries, EXPLICIT_ACCESS_W* pListOfExplicitEntries, ACL* OldAcl, ACL** NewAcl) #uselib "ADVAPI32.dll" #cfunc global SetEntriesInAclW "SetEntriesInAclW" int, intptr, intptr, intptr ; res = SetEntriesInAclW(cCountOfExplicitEntries, varptr(pListOfExplicitEntries), varptr(OldAcl), varptr(NewAcl)) ; cCountOfExplicitEntries : DWORD -> "int" ; pListOfExplicitEntries : EXPLICIT_ACCESS_W* optional -> "intptr" ; OldAcl : ACL* optional -> "intptr" ; NewAcl : ACL** out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
procSetEntriesInAclW = advapi32.NewProc("SetEntriesInAclW")
)
// cCountOfExplicitEntries (DWORD), pListOfExplicitEntries (EXPLICIT_ACCESS_W* optional), OldAcl (ACL* optional), NewAcl (ACL** out)
r1, _, err := procSetEntriesInAclW.Call(
uintptr(cCountOfExplicitEntries),
uintptr(pListOfExplicitEntries),
uintptr(OldAcl),
uintptr(NewAcl),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // WIN32_ERRORfunction SetEntriesInAclW(
cCountOfExplicitEntries: DWORD; // DWORD
pListOfExplicitEntries: Pointer; // EXPLICIT_ACCESS_W* optional
OldAcl: Pointer; // ACL* optional
NewAcl: Pointer // ACL** out
): DWORD; stdcall;
external 'ADVAPI32.dll' name 'SetEntriesInAclW';result := DllCall("ADVAPI32\SetEntriesInAclW"
, "UInt", cCountOfExplicitEntries ; DWORD
, "Ptr", pListOfExplicitEntries ; EXPLICIT_ACCESS_W* optional
, "Ptr", OldAcl ; ACL* optional
, "Ptr", NewAcl ; ACL** out
, "UInt") ; return: WIN32_ERROR●SetEntriesInAclW(cCountOfExplicitEntries, pListOfExplicitEntries, OldAcl, NewAcl) = DLL("ADVAPI32.dll", "dword SetEntriesInAclW(dword, void*, void*, void*)")
# 呼び出し: SetEntriesInAclW(cCountOfExplicitEntries, pListOfExplicitEntries, OldAcl, NewAcl)
# cCountOfExplicitEntries : DWORD -> "dword"
# pListOfExplicitEntries : EXPLICIT_ACCESS_W* optional -> "void*"
# OldAcl : ACL* optional -> "void*"
# NewAcl : ACL** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。