Win32 API 日本語リファレンス
ホームStorage.FileSystem › AlignReservedLog

AlignReservedLog

関数
CLFSログの予約領域に必要なアラインメント済みバイト数を算出する。
DLLclfsw32.dll呼出規約winapiSetLastErrorあり対応OSWindows Vista 以降

シグネチャ

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

BOOL AlignReservedLog(
    void* pvMarshal,
    DWORD cReservedRecords,
    LONGLONG* rgcbReservation,
    LONGLONG* pcbAlignReservation
);

パラメーター

名前方向
pvMarshalvoid*inout
cReservedRecordsDWORDin
rgcbReservationLONGLONG*inout
pcbAlignReservationLONGLONG*inout

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL AlignReservedLog(
    void* pvMarshal,
    DWORD cReservedRecords,
    LONGLONG* rgcbReservation,
    LONGLONG* pcbAlignReservation
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("clfsw32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool AlignReservedLog(
    IntPtr pvMarshal,   // void* in/out
    uint cReservedRecords,   // DWORD
    ref long rgcbReservation,   // LONGLONG* in/out
    ref long pcbAlignReservation   // LONGLONG* in/out
);
<DllImport("clfsw32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function AlignReservedLog(
    pvMarshal As IntPtr,   ' void* in/out
    cReservedRecords As UInteger,   ' DWORD
    ByRef rgcbReservation As Long,   ' LONGLONG* in/out
    ByRef pcbAlignReservation As Long   ' LONGLONG* in/out
) As Boolean
End Function
' pvMarshal : void* in/out
' cReservedRecords : DWORD
' rgcbReservation : LONGLONG* in/out
' pcbAlignReservation : LONGLONG* in/out
Declare PtrSafe Function AlignReservedLog Lib "clfsw32" ( _
    ByVal pvMarshal As LongPtr, _
    ByVal cReservedRecords As Long, _
    ByRef rgcbReservation As LongLong, _
    ByRef pcbAlignReservation As LongLong) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

AlignReservedLog = ctypes.windll.clfsw32.AlignReservedLog
AlignReservedLog.restype = wintypes.BOOL
AlignReservedLog.argtypes = [
    ctypes.POINTER(None),  # pvMarshal : void* in/out
    wintypes.DWORD,  # cReservedRecords : DWORD
    ctypes.POINTER(ctypes.c_longlong),  # rgcbReservation : LONGLONG* in/out
    ctypes.POINTER(ctypes.c_longlong),  # pcbAlignReservation : LONGLONG* in/out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('clfsw32.dll')
AlignReservedLog = Fiddle::Function.new(
  lib['AlignReservedLog'],
  [
    Fiddle::TYPE_VOIDP,  # pvMarshal : void* in/out
    -Fiddle::TYPE_INT,  # cReservedRecords : DWORD
    Fiddle::TYPE_VOIDP,  # rgcbReservation : LONGLONG* in/out
    Fiddle::TYPE_VOIDP,  # pcbAlignReservation : LONGLONG* in/out
  ],
  Fiddle::TYPE_INT)
#[link(name = "clfsw32")]
extern "system" {
    fn AlignReservedLog(
        pvMarshal: *mut (),  // void* in/out
        cReservedRecords: u32,  // DWORD
        rgcbReservation: *mut i64,  // LONGLONG* in/out
        pcbAlignReservation: *mut i64  // LONGLONG* in/out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("clfsw32.dll", SetLastError = true)]
public static extern bool AlignReservedLog(IntPtr pvMarshal, uint cReservedRecords, ref long rgcbReservation, ref long pcbAlignReservation);
"@
$api = Add-Type -MemberDefinition $sig -Name 'clfsw32_AlignReservedLog' -Namespace Win32 -PassThru
# $api::AlignReservedLog(pvMarshal, cReservedRecords, rgcbReservation, pcbAlignReservation)
#uselib "clfsw32.dll"
#func global AlignReservedLog "AlignReservedLog" sptr, sptr, sptr, sptr
; AlignReservedLog pvMarshal, cReservedRecords, varptr(rgcbReservation), varptr(pcbAlignReservation)   ; 戻り値は stat
; pvMarshal : void* in/out -> "sptr"
; cReservedRecords : DWORD -> "sptr"
; rgcbReservation : LONGLONG* in/out -> "sptr"
; pcbAlignReservation : LONGLONG* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "clfsw32.dll"
#cfunc global AlignReservedLog "AlignReservedLog" sptr, int, var, var
; res = AlignReservedLog(pvMarshal, cReservedRecords, rgcbReservation, pcbAlignReservation)
; pvMarshal : void* in/out -> "sptr"
; cReservedRecords : DWORD -> "int"
; rgcbReservation : LONGLONG* in/out -> "var"
; pcbAlignReservation : LONGLONG* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL AlignReservedLog(void* pvMarshal, DWORD cReservedRecords, LONGLONG* rgcbReservation, LONGLONG* pcbAlignReservation)
#uselib "clfsw32.dll"
#cfunc global AlignReservedLog "AlignReservedLog" intptr, int, var, var
; res = AlignReservedLog(pvMarshal, cReservedRecords, rgcbReservation, pcbAlignReservation)
; pvMarshal : void* in/out -> "intptr"
; cReservedRecords : DWORD -> "int"
; rgcbReservation : LONGLONG* in/out -> "var"
; pcbAlignReservation : LONGLONG* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	clfsw32 = windows.NewLazySystemDLL("clfsw32.dll")
	procAlignReservedLog = clfsw32.NewProc("AlignReservedLog")
)

// pvMarshal (void* in/out), cReservedRecords (DWORD), rgcbReservation (LONGLONG* in/out), pcbAlignReservation (LONGLONG* in/out)
r1, _, err := procAlignReservedLog.Call(
	uintptr(pvMarshal),
	uintptr(cReservedRecords),
	uintptr(rgcbReservation),
	uintptr(pcbAlignReservation),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function AlignReservedLog(
  pvMarshal: Pointer;   // void* in/out
  cReservedRecords: DWORD;   // DWORD
  rgcbReservation: Pointer;   // LONGLONG* in/out
  pcbAlignReservation: Pointer   // LONGLONG* in/out
): BOOL; stdcall;
  external 'clfsw32.dll' name 'AlignReservedLog';
result := DllCall("clfsw32\AlignReservedLog"
    , "Ptr", pvMarshal   ; void* in/out
    , "UInt", cReservedRecords   ; DWORD
    , "Ptr", rgcbReservation   ; LONGLONG* in/out
    , "Ptr", pcbAlignReservation   ; LONGLONG* in/out
    , "Int")   ; return: BOOL
●AlignReservedLog(pvMarshal, cReservedRecords, rgcbReservation, pcbAlignReservation) = DLL("clfsw32.dll", "bool AlignReservedLog(void*, dword, void*, void*)")
# 呼び出し: AlignReservedLog(pvMarshal, cReservedRecords, rgcbReservation, pcbAlignReservation)
# pvMarshal : void* in/out -> "void*"
# cReservedRecords : DWORD -> "dword"
# rgcbReservation : LONGLONG* in/out -> "void*"
# pcbAlignReservation : LONGLONG* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。