ホーム › Storage.FileSystem › CreateLogMarshallingArea
CreateLogMarshallingArea
関数CLFSログの読み書きに使うマーシャリング領域を作成する。
シグネチャ
// clfsw32.dll
#include <windows.h>
BOOL CreateLogMarshallingArea(
HANDLE hLog,
CLFS_BLOCK_ALLOCATION pfnAllocBuffer,
CLFS_BLOCK_DEALLOCATION pfnFreeBuffer,
void* pvBlockAllocContext,
DWORD cbMarshallingBuffer,
DWORD cMaxWriteBuffers,
DWORD cMaxReadBuffers,
void** ppvMarshal
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hLog | HANDLE | in |
| pfnAllocBuffer | CLFS_BLOCK_ALLOCATION | in |
| pfnFreeBuffer | CLFS_BLOCK_DEALLOCATION | in |
| pvBlockAllocContext | void* | inout |
| cbMarshallingBuffer | DWORD | in |
| cMaxWriteBuffers | DWORD | in |
| cMaxReadBuffers | DWORD | in |
| ppvMarshal | void** | inout |
戻り値の型: BOOL
各言語での呼び出し定義
// clfsw32.dll
#include <windows.h>
BOOL CreateLogMarshallingArea(
HANDLE hLog,
CLFS_BLOCK_ALLOCATION pfnAllocBuffer,
CLFS_BLOCK_DEALLOCATION pfnFreeBuffer,
void* pvBlockAllocContext,
DWORD cbMarshallingBuffer,
DWORD cMaxWriteBuffers,
DWORD cMaxReadBuffers,
void** ppvMarshal
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("clfsw32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool CreateLogMarshallingArea(
IntPtr hLog, // HANDLE
IntPtr pfnAllocBuffer, // CLFS_BLOCK_ALLOCATION
IntPtr pfnFreeBuffer, // CLFS_BLOCK_DEALLOCATION
IntPtr pvBlockAllocContext, // void* in/out
uint cbMarshallingBuffer, // DWORD
uint cMaxWriteBuffers, // DWORD
uint cMaxReadBuffers, // DWORD
IntPtr ppvMarshal // void** in/out
);<DllImport("clfsw32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function CreateLogMarshallingArea(
hLog As IntPtr, ' HANDLE
pfnAllocBuffer As IntPtr, ' CLFS_BLOCK_ALLOCATION
pfnFreeBuffer As IntPtr, ' CLFS_BLOCK_DEALLOCATION
pvBlockAllocContext As IntPtr, ' void* in/out
cbMarshallingBuffer As UInteger, ' DWORD
cMaxWriteBuffers As UInteger, ' DWORD
cMaxReadBuffers As UInteger, ' DWORD
ppvMarshal As IntPtr ' void** in/out
) As Boolean
End Function' hLog : HANDLE
' pfnAllocBuffer : CLFS_BLOCK_ALLOCATION
' pfnFreeBuffer : CLFS_BLOCK_DEALLOCATION
' pvBlockAllocContext : void* in/out
' cbMarshallingBuffer : DWORD
' cMaxWriteBuffers : DWORD
' cMaxReadBuffers : DWORD
' ppvMarshal : void** in/out
Declare PtrSafe Function CreateLogMarshallingArea Lib "clfsw32" ( _
ByVal hLog As LongPtr, _
ByVal pfnAllocBuffer As LongPtr, _
ByVal pfnFreeBuffer As LongPtr, _
ByVal pvBlockAllocContext As LongPtr, _
ByVal cbMarshallingBuffer As Long, _
ByVal cMaxWriteBuffers As Long, _
ByVal cMaxReadBuffers As Long, _
ByVal ppvMarshal As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CreateLogMarshallingArea = ctypes.windll.clfsw32.CreateLogMarshallingArea
CreateLogMarshallingArea.restype = wintypes.BOOL
CreateLogMarshallingArea.argtypes = [
wintypes.HANDLE, # hLog : HANDLE
ctypes.c_void_p, # pfnAllocBuffer : CLFS_BLOCK_ALLOCATION
ctypes.c_void_p, # pfnFreeBuffer : CLFS_BLOCK_DEALLOCATION
ctypes.POINTER(None), # pvBlockAllocContext : void* in/out
wintypes.DWORD, # cbMarshallingBuffer : DWORD
wintypes.DWORD, # cMaxWriteBuffers : DWORD
wintypes.DWORD, # cMaxReadBuffers : DWORD
ctypes.c_void_p, # ppvMarshal : void** in/out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('clfsw32.dll')
CreateLogMarshallingArea = Fiddle::Function.new(
lib['CreateLogMarshallingArea'],
[
Fiddle::TYPE_VOIDP, # hLog : HANDLE
Fiddle::TYPE_VOIDP, # pfnAllocBuffer : CLFS_BLOCK_ALLOCATION
Fiddle::TYPE_VOIDP, # pfnFreeBuffer : CLFS_BLOCK_DEALLOCATION
Fiddle::TYPE_VOIDP, # pvBlockAllocContext : void* in/out
-Fiddle::TYPE_INT, # cbMarshallingBuffer : DWORD
-Fiddle::TYPE_INT, # cMaxWriteBuffers : DWORD
-Fiddle::TYPE_INT, # cMaxReadBuffers : DWORD
Fiddle::TYPE_VOIDP, # ppvMarshal : void** in/out
],
Fiddle::TYPE_INT)#[link(name = "clfsw32")]
extern "system" {
fn CreateLogMarshallingArea(
hLog: *mut core::ffi::c_void, // HANDLE
pfnAllocBuffer: *const core::ffi::c_void, // CLFS_BLOCK_ALLOCATION
pfnFreeBuffer: *const core::ffi::c_void, // CLFS_BLOCK_DEALLOCATION
pvBlockAllocContext: *mut (), // void* in/out
cbMarshallingBuffer: u32, // DWORD
cMaxWriteBuffers: u32, // DWORD
cMaxReadBuffers: u32, // DWORD
ppvMarshal: *mut *mut () // void** 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 CreateLogMarshallingArea(IntPtr hLog, IntPtr pfnAllocBuffer, IntPtr pfnFreeBuffer, IntPtr pvBlockAllocContext, uint cbMarshallingBuffer, uint cMaxWriteBuffers, uint cMaxReadBuffers, IntPtr ppvMarshal);
"@
$api = Add-Type -MemberDefinition $sig -Name 'clfsw32_CreateLogMarshallingArea' -Namespace Win32 -PassThru
# $api::CreateLogMarshallingArea(hLog, pfnAllocBuffer, pfnFreeBuffer, pvBlockAllocContext, cbMarshallingBuffer, cMaxWriteBuffers, cMaxReadBuffers, ppvMarshal)#uselib "clfsw32.dll"
#func global CreateLogMarshallingArea "CreateLogMarshallingArea" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; CreateLogMarshallingArea hLog, pfnAllocBuffer, pfnFreeBuffer, pvBlockAllocContext, cbMarshallingBuffer, cMaxWriteBuffers, cMaxReadBuffers, ppvMarshal ; 戻り値は stat
; hLog : HANDLE -> "sptr"
; pfnAllocBuffer : CLFS_BLOCK_ALLOCATION -> "sptr"
; pfnFreeBuffer : CLFS_BLOCK_DEALLOCATION -> "sptr"
; pvBlockAllocContext : void* in/out -> "sptr"
; cbMarshallingBuffer : DWORD -> "sptr"
; cMaxWriteBuffers : DWORD -> "sptr"
; cMaxReadBuffers : DWORD -> "sptr"
; ppvMarshal : void** in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "clfsw32.dll"
#cfunc global CreateLogMarshallingArea "CreateLogMarshallingArea" sptr, sptr, sptr, sptr, int, int, int, sptr
; res = CreateLogMarshallingArea(hLog, pfnAllocBuffer, pfnFreeBuffer, pvBlockAllocContext, cbMarshallingBuffer, cMaxWriteBuffers, cMaxReadBuffers, ppvMarshal)
; hLog : HANDLE -> "sptr"
; pfnAllocBuffer : CLFS_BLOCK_ALLOCATION -> "sptr"
; pfnFreeBuffer : CLFS_BLOCK_DEALLOCATION -> "sptr"
; pvBlockAllocContext : void* in/out -> "sptr"
; cbMarshallingBuffer : DWORD -> "int"
; cMaxWriteBuffers : DWORD -> "int"
; cMaxReadBuffers : DWORD -> "int"
; ppvMarshal : void** in/out -> "sptr"; BOOL CreateLogMarshallingArea(HANDLE hLog, CLFS_BLOCK_ALLOCATION pfnAllocBuffer, CLFS_BLOCK_DEALLOCATION pfnFreeBuffer, void* pvBlockAllocContext, DWORD cbMarshallingBuffer, DWORD cMaxWriteBuffers, DWORD cMaxReadBuffers, void** ppvMarshal)
#uselib "clfsw32.dll"
#cfunc global CreateLogMarshallingArea "CreateLogMarshallingArea" intptr, intptr, intptr, intptr, int, int, int, intptr
; res = CreateLogMarshallingArea(hLog, pfnAllocBuffer, pfnFreeBuffer, pvBlockAllocContext, cbMarshallingBuffer, cMaxWriteBuffers, cMaxReadBuffers, ppvMarshal)
; hLog : HANDLE -> "intptr"
; pfnAllocBuffer : CLFS_BLOCK_ALLOCATION -> "intptr"
; pfnFreeBuffer : CLFS_BLOCK_DEALLOCATION -> "intptr"
; pvBlockAllocContext : void* in/out -> "intptr"
; cbMarshallingBuffer : DWORD -> "int"
; cMaxWriteBuffers : DWORD -> "int"
; cMaxReadBuffers : DWORD -> "int"
; ppvMarshal : void** in/out -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
clfsw32 = windows.NewLazySystemDLL("clfsw32.dll")
procCreateLogMarshallingArea = clfsw32.NewProc("CreateLogMarshallingArea")
)
// hLog (HANDLE), pfnAllocBuffer (CLFS_BLOCK_ALLOCATION), pfnFreeBuffer (CLFS_BLOCK_DEALLOCATION), pvBlockAllocContext (void* in/out), cbMarshallingBuffer (DWORD), cMaxWriteBuffers (DWORD), cMaxReadBuffers (DWORD), ppvMarshal (void** in/out)
r1, _, err := procCreateLogMarshallingArea.Call(
uintptr(hLog),
uintptr(pfnAllocBuffer),
uintptr(pfnFreeBuffer),
uintptr(pvBlockAllocContext),
uintptr(cbMarshallingBuffer),
uintptr(cMaxWriteBuffers),
uintptr(cMaxReadBuffers),
uintptr(ppvMarshal),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction CreateLogMarshallingArea(
hLog: THandle; // HANDLE
pfnAllocBuffer: Pointer; // CLFS_BLOCK_ALLOCATION
pfnFreeBuffer: Pointer; // CLFS_BLOCK_DEALLOCATION
pvBlockAllocContext: Pointer; // void* in/out
cbMarshallingBuffer: DWORD; // DWORD
cMaxWriteBuffers: DWORD; // DWORD
cMaxReadBuffers: DWORD; // DWORD
ppvMarshal: Pointer // void** in/out
): BOOL; stdcall;
external 'clfsw32.dll' name 'CreateLogMarshallingArea';result := DllCall("clfsw32\CreateLogMarshallingArea"
, "Ptr", hLog ; HANDLE
, "Ptr", pfnAllocBuffer ; CLFS_BLOCK_ALLOCATION
, "Ptr", pfnFreeBuffer ; CLFS_BLOCK_DEALLOCATION
, "Ptr", pvBlockAllocContext ; void* in/out
, "UInt", cbMarshallingBuffer ; DWORD
, "UInt", cMaxWriteBuffers ; DWORD
, "UInt", cMaxReadBuffers ; DWORD
, "Ptr", ppvMarshal ; void** in/out
, "Int") ; return: BOOL●CreateLogMarshallingArea(hLog, pfnAllocBuffer, pfnFreeBuffer, pvBlockAllocContext, cbMarshallingBuffer, cMaxWriteBuffers, cMaxReadBuffers, ppvMarshal) = DLL("clfsw32.dll", "bool CreateLogMarshallingArea(void*, void*, void*, void*, dword, dword, dword, void*)")
# 呼び出し: CreateLogMarshallingArea(hLog, pfnAllocBuffer, pfnFreeBuffer, pvBlockAllocContext, cbMarshallingBuffer, cMaxWriteBuffers, cMaxReadBuffers, ppvMarshal)
# hLog : HANDLE -> "void*"
# pfnAllocBuffer : CLFS_BLOCK_ALLOCATION -> "void*"
# pfnFreeBuffer : CLFS_BLOCK_DEALLOCATION -> "void*"
# pvBlockAllocContext : void* in/out -> "void*"
# cbMarshallingBuffer : DWORD -> "dword"
# cMaxWriteBuffers : DWORD -> "dword"
# cMaxReadBuffers : DWORD -> "dword"
# ppvMarshal : void** in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。