ホーム › Storage.FileSystem › AlignReservedLog
AlignReservedLog
関数CLFSログの予約領域に必要なアラインメント済みバイト数を算出する。
シグネチャ
// clfsw32.dll
#include <windows.h>
BOOL AlignReservedLog(
void* pvMarshal,
DWORD cReservedRecords,
LONGLONG* rgcbReservation,
LONGLONG* pcbAlignReservation
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pvMarshal | void* | inout | CreateLogMarshallingArea 関数を呼び出して割り当てられた、不透明なマーシャリングコンテキストへのポインターです。 |
| cReservedRecords | DWORD | in | 予約調整に関連付けられた予約レコードの数です。 |
| rgcbReservation | LONGLONG* | inout | 現在のマーシャリングコンテキストに関連付けられたログ内に予約する領域割り当ての配列で、バイト単位で指定します。 割り当ての数は、cReservedRecords で指定されるレコードの数に対応します。各割り当ては 0 より大きい値でなければなりません。そうでない場合、関数は ERROR_INVALID_PARAMETER で失敗します。 |
| pcbAlignReservation | LONGLONG* | inout | cRecords で指定されるレコードの数と rgcbReservation 配列で指定される予約サイズが与えられたうえで、ログ内に予約するセクターアラインメントされたバイト領域の数を関数が返す変数へのポインターです。 *pcbAlignReservation に返される値は、AllocReservedLog への入力として使用されます。AllocReservedLog が成功した場合、この値は常に 0 より大きくなります。AllocReservedLog が失敗した場合、値は 0 になります。 |
戻り値の型: BOOL
公式ドキュメント
予約レコードのセットに対して、セクターアラインメントされた予約サイズを計算します。
戻り値
関数が成功した場合、戻り値は 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)
各言語での呼び出し定義
// 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 <MarshalAs(UnmanagedType.Bool)> 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 方式にも切替可。#uselib "clfsw32.dll" #cfunc global AlignReservedLog "AlignReservedLog" sptr, int, sptr, sptr ; res = AlignReservedLog(pvMarshal, cReservedRecords, varptr(rgcbReservation), varptr(pcbAlignReservation)) ; pvMarshal : void* in/out -> "sptr" ; cReservedRecords : DWORD -> "int" ; rgcbReservation : LONGLONG* in/out -> "sptr" ; pcbAlignReservation : LONGLONG* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは 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 方式にも切替可。; BOOL AlignReservedLog(void* pvMarshal, DWORD cReservedRecords, LONGLONG* rgcbReservation, LONGLONG* pcbAlignReservation) #uselib "clfsw32.dll" #cfunc global AlignReservedLog "AlignReservedLog" intptr, int, intptr, intptr ; res = AlignReservedLog(pvMarshal, cReservedRecords, varptr(rgcbReservation), varptr(pcbAlignReservation)) ; pvMarshal : void* in/out -> "intptr" ; cReservedRecords : DWORD -> "int" ; rgcbReservation : LONGLONG* in/out -> "intptr" ; pcbAlignReservation : LONGLONG* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは 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 // BOOLfunction 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)。const std = @import("std");
extern "clfsw32" fn AlignReservedLog(
pvMarshal: ?*anyopaque, // void* in/out
cReservedRecords: u32, // DWORD
rgcbReservation: [*c]i64, // LONGLONG* in/out
pcbAlignReservation: [*c]i64 // LONGLONG* in/out
) callconv(std.os.windows.WINAPI) i32;proc AlignReservedLog(
pvMarshal: pointer, # void* in/out
cReservedRecords: uint32, # DWORD
rgcbReservation: ptr int64, # LONGLONG* in/out
pcbAlignReservation: ptr int64 # LONGLONG* in/out
): int32 {.importc: "AlignReservedLog", stdcall, dynlib: "clfsw32.dll".}pragma(lib, "clfsw32");
extern(Windows)
int AlignReservedLog(
void* pvMarshal, // void* in/out
uint cReservedRecords, // DWORD
long* rgcbReservation, // LONGLONG* in/out
long* pcbAlignReservation // LONGLONG* in/out
);ccall((:AlignReservedLog, "clfsw32.dll"), stdcall, Int32,
(Ptr{Cvoid}, UInt32, Ptr{Int64}, Ptr{Int64}),
pvMarshal, cReservedRecords, rgcbReservation, pcbAlignReservation)
# pvMarshal : void* in/out -> Ptr{Cvoid}
# cReservedRecords : DWORD -> UInt32
# rgcbReservation : LONGLONG* in/out -> Ptr{Int64}
# pcbAlignReservation : LONGLONG* in/out -> Ptr{Int64}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t AlignReservedLog(
void* pvMarshal,
uint32_t cReservedRecords,
int64_t* rgcbReservation,
int64_t* pcbAlignReservation);
]]
local clfsw32 = ffi.load("clfsw32")
-- clfsw32.AlignReservedLog(pvMarshal, cReservedRecords, rgcbReservation, pcbAlignReservation)
-- pvMarshal : void* in/out
-- cReservedRecords : DWORD
-- rgcbReservation : LONGLONG* in/out
-- pcbAlignReservation : LONGLONG* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('clfsw32.dll');
const AlignReservedLog = lib.func('__stdcall', 'AlignReservedLog', 'int32_t', ['void *', 'uint32_t', 'int64_t *', 'int64_t *']);
// AlignReservedLog(pvMarshal, cReservedRecords, rgcbReservation, pcbAlignReservation)
// pvMarshal : void* in/out -> 'void *'
// cReservedRecords : DWORD -> 'uint32_t'
// rgcbReservation : LONGLONG* in/out -> 'int64_t *'
// pcbAlignReservation : LONGLONG* in/out -> 'int64_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("clfsw32.dll", {
AlignReservedLog: { parameters: ["pointer", "u32", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.AlignReservedLog(pvMarshal, cReservedRecords, rgcbReservation, pcbAlignReservation)
// pvMarshal : void* in/out -> "pointer"
// cReservedRecords : DWORD -> "u32"
// rgcbReservation : LONGLONG* in/out -> "pointer"
// pcbAlignReservation : LONGLONG* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t AlignReservedLog(
void* pvMarshal,
uint32_t cReservedRecords,
int64_t* rgcbReservation,
int64_t* pcbAlignReservation);
C, "clfsw32.dll");
// $ffi->AlignReservedLog(pvMarshal, cReservedRecords, rgcbReservation, pcbAlignReservation);
// pvMarshal : void* in/out
// cReservedRecords : DWORD
// rgcbReservation : LONGLONG* in/out
// pcbAlignReservation : LONGLONG* in/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 Clfsw32 extends StdCallLibrary {
Clfsw32 INSTANCE = Native.load("clfsw32", Clfsw32.class);
boolean AlignReservedLog(
Pointer pvMarshal, // void* in/out
int cReservedRecords, // DWORD
LongByReference rgcbReservation, // LONGLONG* in/out
LongByReference pcbAlignReservation // LONGLONG* in/out
);
}@[Link("clfsw32")]
lib Libclfsw32
fun AlignReservedLog = AlignReservedLog(
pvMarshal : Void*, # void* in/out
cReservedRecords : UInt32, # DWORD
rgcbReservation : Int64*, # LONGLONG* in/out
pcbAlignReservation : Int64* # LONGLONG* in/out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef AlignReservedLogNative = Int32 Function(Pointer<Void>, Uint32, Pointer<Int64>, Pointer<Int64>);
typedef AlignReservedLogDart = int Function(Pointer<Void>, int, Pointer<Int64>, Pointer<Int64>);
final AlignReservedLog = DynamicLibrary.open('clfsw32.dll')
.lookupFunction<AlignReservedLogNative, AlignReservedLogDart>('AlignReservedLog');
// pvMarshal : void* in/out -> Pointer<Void>
// cReservedRecords : DWORD -> Uint32
// rgcbReservation : LONGLONG* in/out -> Pointer<Int64>
// pcbAlignReservation : LONGLONG* in/out -> Pointer<Int64>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
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';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "AlignReservedLog"
c_AlignReservedLog :: Ptr () -> Word32 -> Ptr Int64 -> Ptr Int64 -> IO CInt
-- pvMarshal : void* in/out -> Ptr ()
-- cReservedRecords : DWORD -> Word32
-- rgcbReservation : LONGLONG* in/out -> Ptr Int64
-- pcbAlignReservation : LONGLONG* in/out -> Ptr Int64
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let alignreservedlog =
foreign "AlignReservedLog"
((ptr void) @-> uint32_t @-> (ptr int64_t) @-> (ptr int64_t) @-> returning int32_t)
(* pvMarshal : void* in/out -> (ptr void) *)
(* cReservedRecords : DWORD -> uint32_t *)
(* rgcbReservation : LONGLONG* in/out -> (ptr int64_t) *)
(* pcbAlignReservation : LONGLONG* in/out -> (ptr int64_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library clfsw32 (t "clfsw32.dll"))
(cffi:use-foreign-library clfsw32)
(cffi:defcfun ("AlignReservedLog" align-reserved-log :convention :stdcall) :int32
(pv-marshal :pointer) ; void* in/out
(c-reserved-records :uint32) ; DWORD
(rgcb-reservation :pointer) ; LONGLONG* in/out
(pcb-align-reservation :pointer)) ; LONGLONG* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $AlignReservedLog = Win32::API::More->new('clfsw32',
'BOOL AlignReservedLog(LPVOID pvMarshal, DWORD cReservedRecords, LPVOID rgcbReservation, LPVOID pcbAlignReservation)');
# my $ret = $AlignReservedLog->Call($pvMarshal, $cReservedRecords, $rgcbReservation, $pcbAlignReservation);
# pvMarshal : void* in/out -> LPVOID
# cReservedRecords : DWORD -> DWORD
# rgcbReservation : LONGLONG* in/out -> LPVOID
# pcbAlignReservation : LONGLONG* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
公式の関連項目
- f AllocReservedLog — CLFSマーシャリング領域にログ書き込み用の領域を予約する。