FindFirstFreeAce
関数ACL内の最初の空き領域の位置を取得する。
シグネチャ
// ADVAPI32.dll
#include <windows.h>
BOOL FindFirstFreeAce(
ACL* pAcl,
void** pAce
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pAcl | ACL* | in | ACL へのポインター。 |
| pAce | void** | out | 関数が返るときに作成される、ACL 内の最初の空き位置へのポインターのアドレス。ACL が無効な場合、このパラメーターは NULL になります。ACL が満杯の場合、このパラメーターは ACL の直後のバイトを指します。 |
戻り値の型: 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 FindFirstFreeAce(
ACL* pAcl,
void** pAce
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("ADVAPI32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool FindFirstFreeAce(
IntPtr pAcl, // ACL*
IntPtr pAce // void** out
);<DllImport("ADVAPI32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function FindFirstFreeAce(
pAcl As IntPtr, ' ACL*
pAce As IntPtr ' void** out
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' pAcl : ACL*
' pAce : void** out
Declare PtrSafe Function FindFirstFreeAce Lib "advapi32" ( _
ByVal pAcl As LongPtr, _
ByVal pAce As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
FindFirstFreeAce = ctypes.windll.advapi32.FindFirstFreeAce
FindFirstFreeAce.restype = wintypes.BOOL
FindFirstFreeAce.argtypes = [
ctypes.c_void_p, # pAcl : ACL*
ctypes.c_void_p, # pAce : void** out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ADVAPI32.dll')
FindFirstFreeAce = Fiddle::Function.new(
lib['FindFirstFreeAce'],
[
Fiddle::TYPE_VOIDP, # pAcl : ACL*
Fiddle::TYPE_VOIDP, # pAce : void** out
],
Fiddle::TYPE_INT)#[link(name = "advapi32")]
extern "system" {
fn FindFirstFreeAce(
pAcl: *mut ACL, // ACL*
pAce: *mut *mut () // void** out
) -> 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 FindFirstFreeAce(IntPtr pAcl, IntPtr pAce);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVAPI32_FindFirstFreeAce' -Namespace Win32 -PassThru
# $api::FindFirstFreeAce(pAcl, pAce)#uselib "ADVAPI32.dll"
#func global FindFirstFreeAce "FindFirstFreeAce" sptr, sptr
; FindFirstFreeAce varptr(pAcl), pAce ; 戻り値は stat
; pAcl : ACL* -> "sptr"
; pAce : void** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "ADVAPI32.dll" #cfunc global FindFirstFreeAce "FindFirstFreeAce" var, sptr ; res = FindFirstFreeAce(pAcl, pAce) ; pAcl : ACL* -> "var" ; pAce : void** out -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ADVAPI32.dll" #cfunc global FindFirstFreeAce "FindFirstFreeAce" sptr, sptr ; res = FindFirstFreeAce(varptr(pAcl), pAce) ; pAcl : ACL* -> "sptr" ; pAce : void** out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL FindFirstFreeAce(ACL* pAcl, void** pAce) #uselib "ADVAPI32.dll" #cfunc global FindFirstFreeAce "FindFirstFreeAce" var, intptr ; res = FindFirstFreeAce(pAcl, pAce) ; pAcl : ACL* -> "var" ; pAce : void** out -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL FindFirstFreeAce(ACL* pAcl, void** pAce) #uselib "ADVAPI32.dll" #cfunc global FindFirstFreeAce "FindFirstFreeAce" intptr, intptr ; res = FindFirstFreeAce(varptr(pAcl), pAce) ; pAcl : ACL* -> "intptr" ; pAce : void** out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
procFindFirstFreeAce = advapi32.NewProc("FindFirstFreeAce")
)
// pAcl (ACL*), pAce (void** out)
r1, _, err := procFindFirstFreeAce.Call(
uintptr(pAcl),
uintptr(pAce),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction FindFirstFreeAce(
pAcl: Pointer; // ACL*
pAce: Pointer // void** out
): BOOL; stdcall;
external 'ADVAPI32.dll' name 'FindFirstFreeAce';result := DllCall("ADVAPI32\FindFirstFreeAce"
, "Ptr", pAcl ; ACL*
, "Ptr", pAce ; void** out
, "Int") ; return: BOOL●FindFirstFreeAce(pAcl, pAce) = DLL("ADVAPI32.dll", "bool FindFirstFreeAce(void*, void*)")
# 呼び出し: FindFirstFreeAce(pAcl, pAce)
# pAcl : ACL* -> "void*"
# pAce : void** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "advapi32" fn FindFirstFreeAce(
pAcl: [*c]ACL, // ACL*
pAce: ?*anyopaque // void** out
) callconv(std.os.windows.WINAPI) i32;proc FindFirstFreeAce(
pAcl: ptr ACL, # ACL*
pAce: pointer # void** out
): int32 {.importc: "FindFirstFreeAce", stdcall, dynlib: "ADVAPI32.dll".}pragma(lib, "advapi32");
extern(Windows)
int FindFirstFreeAce(
ACL* pAcl, // ACL*
void** pAce // void** out
);ccall((:FindFirstFreeAce, "ADVAPI32.dll"), stdcall, Int32,
(Ptr{ACL}, Ptr{Cvoid}),
pAcl, pAce)
# pAcl : ACL* -> Ptr{ACL}
# pAce : void** out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t FindFirstFreeAce(
void* pAcl,
void** pAce);
]]
local advapi32 = ffi.load("advapi32")
-- advapi32.FindFirstFreeAce(pAcl, pAce)
-- pAcl : ACL*
-- pAce : void** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('ADVAPI32.dll');
const FindFirstFreeAce = lib.func('__stdcall', 'FindFirstFreeAce', 'int32_t', ['void *', 'void *']);
// FindFirstFreeAce(pAcl, pAce)
// pAcl : ACL* -> 'void *'
// pAce : void** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("ADVAPI32.dll", {
FindFirstFreeAce: { parameters: ["pointer", "pointer"], result: "i32" },
});
// lib.symbols.FindFirstFreeAce(pAcl, pAce)
// pAcl : ACL* -> "pointer"
// pAce : void** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t FindFirstFreeAce(
void* pAcl,
void** pAce);
C, "ADVAPI32.dll");
// $ffi->FindFirstFreeAce(pAcl, pAce);
// pAcl : ACL*
// pAce : void** out
// 構造体/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 FindFirstFreeAce(
Pointer pAcl, // ACL*
Pointer pAce // void** out
);
}@[Link("advapi32")]
lib LibADVAPI32
fun FindFirstFreeAce = FindFirstFreeAce(
pAcl : ACL*, # ACL*
pAce : Void** # void** out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef FindFirstFreeAceNative = Int32 Function(Pointer<Void>, Pointer<Void>);
typedef FindFirstFreeAceDart = int Function(Pointer<Void>, Pointer<Void>);
final FindFirstFreeAce = DynamicLibrary.open('ADVAPI32.dll')
.lookupFunction<FindFirstFreeAceNative, FindFirstFreeAceDart>('FindFirstFreeAce');
// pAcl : ACL* -> Pointer<Void>
// pAce : void** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function FindFirstFreeAce(
pAcl: Pointer; // ACL*
pAce: Pointer // void** out
): BOOL; stdcall;
external 'ADVAPI32.dll' name 'FindFirstFreeAce';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "FindFirstFreeAce"
c_FindFirstFreeAce :: Ptr () -> Ptr () -> IO CInt
-- pAcl : ACL* -> Ptr ()
-- pAce : void** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let findfirstfreeace =
foreign "FindFirstFreeAce"
((ptr void) @-> (ptr void) @-> returning int32_t)
(* pAcl : ACL* -> (ptr void) *)
(* pAce : void** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library advapi32 (t "ADVAPI32.dll"))
(cffi:use-foreign-library advapi32)
(cffi:defcfun ("FindFirstFreeAce" find-first-free-ace :convention :stdcall) :int32
(p-acl :pointer) ; ACL*
(p-ace :pointer)) ; void** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $FindFirstFreeAce = Win32::API::More->new('ADVAPI32',
'BOOL FindFirstFreeAce(LPVOID pAcl, LPVOID pAce)');
# my $ret = $FindFirstFreeAce->Call($pAcl, $pAce);
# pAcl : ACL* -> LPVOID
# pAce : void** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
公式の関連項目
- f GetAce — ACLから指定インデックスのACEへのポインターを取得する。
- f GetAclInformation — ACLの情報(サイズや改訂など)を取得する。
使用する型