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

AllocReservedLog

関数
CLFSマーシャリング領域にログ書き込み用の領域を予約する。
DLLclfsw32.dll呼出規約winapiSetLastErrorあり対応OSWindows Vista 以降

シグネチャ

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

BOOL AllocReservedLog(
    void* pvMarshal,
    DWORD cReservedRecords,
    LONGLONG* pcbAdjustment
);

パラメーター

名前方向
pvMarshalvoid*inout
cReservedRecordsDWORDin
pcbAdjustmentLONGLONG*inout

戻り値の型: BOOL

各言語での呼び出し定義

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

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

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

lib = Fiddle.dlopen('clfsw32.dll')
AllocReservedLog = Fiddle::Function.new(
  lib['AllocReservedLog'],
  [
    Fiddle::TYPE_VOIDP,  # pvMarshal : void* in/out
    -Fiddle::TYPE_INT,  # cReservedRecords : DWORD
    Fiddle::TYPE_VOIDP,  # pcbAdjustment : LONGLONG* in/out
  ],
  Fiddle::TYPE_INT)
#[link(name = "clfsw32")]
extern "system" {
    fn AllocReservedLog(
        pvMarshal: *mut (),  // void* in/out
        cReservedRecords: u32,  // DWORD
        pcbAdjustment: *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 AllocReservedLog(IntPtr pvMarshal, uint cReservedRecords, ref long pcbAdjustment);
"@
$api = Add-Type -MemberDefinition $sig -Name 'clfsw32_AllocReservedLog' -Namespace Win32 -PassThru
# $api::AllocReservedLog(pvMarshal, cReservedRecords, pcbAdjustment)
#uselib "clfsw32.dll"
#func global AllocReservedLog "AllocReservedLog" sptr, sptr, sptr
; AllocReservedLog pvMarshal, cReservedRecords, varptr(pcbAdjustment)   ; 戻り値は stat
; pvMarshal : void* in/out -> "sptr"
; cReservedRecords : DWORD -> "sptr"
; pcbAdjustment : LONGLONG* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "clfsw32.dll"
#cfunc global AllocReservedLog "AllocReservedLog" sptr, int, var
; res = AllocReservedLog(pvMarshal, cReservedRecords, pcbAdjustment)
; pvMarshal : void* in/out -> "sptr"
; cReservedRecords : DWORD -> "int"
; pcbAdjustment : LONGLONG* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL AllocReservedLog(void* pvMarshal, DWORD cReservedRecords, LONGLONG* pcbAdjustment)
#uselib "clfsw32.dll"
#cfunc global AllocReservedLog "AllocReservedLog" intptr, int, var
; res = AllocReservedLog(pvMarshal, cReservedRecords, pcbAdjustment)
; pvMarshal : void* in/out -> "intptr"
; cReservedRecords : DWORD -> "int"
; pcbAdjustment : LONGLONG* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	clfsw32 = windows.NewLazySystemDLL("clfsw32.dll")
	procAllocReservedLog = clfsw32.NewProc("AllocReservedLog")
)

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