Win32 API 日本語リファレンス
ホームSecurity.Authentication.Identity › AuditSetGlobalSaclW

AuditSetGlobalSaclW

関数
指定オブジェクト種別のグローバルSACLを設定する(Unicode版)。
DLLADVAPI32.dll文字セットUnicode (-W)呼出規約winapiSetLastErrorあり対応OSWindows 7 以降

シグネチャ

// ADVAPI32.dll  (Unicode / -W)
#include <windows.h>

BOOLEAN AuditSetGlobalSaclW(
    LPCWSTR ObjectTypeName,
    ACL* Acl   // optional
);

パラメーター

名前方向
ObjectTypeNameLPCWSTRin
AclACL*inoptional

戻り値の型: BOOLEAN

各言語での呼び出し定義

// ADVAPI32.dll  (Unicode / -W)
#include <windows.h>

BOOLEAN AuditSetGlobalSaclW(
    LPCWSTR ObjectTypeName,
    ACL* Acl   // optional
);
[DllImport("ADVAPI32.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern byte AuditSetGlobalSaclW(
    [MarshalAs(UnmanagedType.LPWStr)] string ObjectTypeName,   // LPCWSTR
    IntPtr Acl   // ACL* optional
);
<DllImport("ADVAPI32.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function AuditSetGlobalSaclW(
    <MarshalAs(UnmanagedType.LPWStr)> ObjectTypeName As String,   ' LPCWSTR
    Acl As IntPtr   ' ACL* optional
) As Byte
End Function
' ObjectTypeName : LPCWSTR
' Acl : ACL* optional
Declare PtrSafe Function AuditSetGlobalSaclW Lib "advapi32" ( _
    ByVal ObjectTypeName As LongPtr, _
    ByVal Acl As LongPtr) As Byte
' 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

AuditSetGlobalSaclW = ctypes.windll.advapi32.AuditSetGlobalSaclW
AuditSetGlobalSaclW.restype = ctypes.c_byte
AuditSetGlobalSaclW.argtypes = [
    wintypes.LPCWSTR,  # ObjectTypeName : LPCWSTR
    ctypes.c_void_p,  # Acl : ACL* optional
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('ADVAPI32.dll')
AuditSetGlobalSaclW = Fiddle::Function.new(
  lib['AuditSetGlobalSaclW'],
  [
    Fiddle::TYPE_VOIDP,  # ObjectTypeName : LPCWSTR
    Fiddle::TYPE_VOIDP,  # Acl : ACL* optional
  ],
  Fiddle::TYPE_CHAR)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "advapi32")]
extern "system" {
    fn AuditSetGlobalSaclW(
        ObjectTypeName: *const u16,  // LPCWSTR
        Acl: *mut ACL  // ACL* optional
    ) -> u8;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("ADVAPI32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern byte AuditSetGlobalSaclW([MarshalAs(UnmanagedType.LPWStr)] string ObjectTypeName, IntPtr Acl);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVAPI32_AuditSetGlobalSaclW' -Namespace Win32 -PassThru
# $api::AuditSetGlobalSaclW(ObjectTypeName, Acl)
#uselib "ADVAPI32.dll"
#func global AuditSetGlobalSaclW "AuditSetGlobalSaclW" wptr, wptr
; AuditSetGlobalSaclW ObjectTypeName, varptr(Acl)   ; 戻り値は stat
; ObjectTypeName : LPCWSTR -> "wptr"
; Acl : ACL* optional -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "ADVAPI32.dll"
#cfunc global AuditSetGlobalSaclW "AuditSetGlobalSaclW" wstr, var
; res = AuditSetGlobalSaclW(ObjectTypeName, Acl)
; ObjectTypeName : LPCWSTR -> "wstr"
; Acl : ACL* optional -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOLEAN AuditSetGlobalSaclW(LPCWSTR ObjectTypeName, ACL* Acl)
#uselib "ADVAPI32.dll"
#cfunc global AuditSetGlobalSaclW "AuditSetGlobalSaclW" wstr, var
; res = AuditSetGlobalSaclW(ObjectTypeName, Acl)
; ObjectTypeName : LPCWSTR -> "wstr"
; Acl : ACL* optional -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
	procAuditSetGlobalSaclW = advapi32.NewProc("AuditSetGlobalSaclW")
)

// ObjectTypeName (LPCWSTR), Acl (ACL* optional)
r1, _, err := procAuditSetGlobalSaclW.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(ObjectTypeName))),
	uintptr(Acl),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOLEAN
function AuditSetGlobalSaclW(
  ObjectTypeName: PWideChar;   // LPCWSTR
  Acl: Pointer   // ACL* optional
): ByteBool; stdcall;
  external 'ADVAPI32.dll' name 'AuditSetGlobalSaclW';
result := DllCall("ADVAPI32\AuditSetGlobalSaclW"
    , "WStr", ObjectTypeName   ; LPCWSTR
    , "Ptr", Acl   ; ACL* optional
    , "Char")   ; return: BOOLEAN
●AuditSetGlobalSaclW(ObjectTypeName, Acl) = DLL("ADVAPI32.dll", "byte AuditSetGlobalSaclW(char*, void*)")
# 呼び出し: AuditSetGlobalSaclW(ObjectTypeName, Acl)
# ObjectTypeName : LPCWSTR -> "char*"
# Acl : ACL* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。