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

TxfLogCreateFileReadContext

関数
TxFログから特定ファイルのレコード読み取りコンテキストを作成する。
DLLtxfw32.dll呼出規約winapiSetLastErrorあり対応OSWindows Vista 以降

シグネチャ

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

BOOL TxfLogCreateFileReadContext(
    LPCWSTR LogPath,
    CLS_LSN BeginningLsn,
    CLS_LSN EndingLsn,
    TXF_ID* TxfFileId,
    void** TxfLogContext
);

パラメーター

名前方向説明
LogPathLPCWSTRinリソース マネージャーの .blf ファイルを識別するパス。
BeginningLsnCLS_LSNin読み取る範囲の最初の LSN。
EndingLsnCLS_LSNin読み取る範囲の最後の LSN。
TxfFileIdTXF_ID*inLSN の範囲内で検索する TxF 識別子。詳細については、TXF_ID を参照してください。
TxfLogContextvoid**out作成されたコンテキストへのポインター。

戻り値の型: BOOL

公式ドキュメント

レプリケーション レコードの読み取りに使用するコンテキストを作成します。

戻り値

関数が成功した場合、戻り値は 0 以外の値になります。

関数が失敗した場合、戻り値は 0 になります。拡張エラー情報を取得するには、 GetLastError を呼び出します。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

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

BOOL TxfLogCreateFileReadContext(
    LPCWSTR LogPath,
    CLS_LSN BeginningLsn,
    CLS_LSN EndingLsn,
    TXF_ID* TxfFileId,
    void** TxfLogContext
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("txfw32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool TxfLogCreateFileReadContext(
    [MarshalAs(UnmanagedType.LPWStr)] string LogPath,   // LPCWSTR
    CLS_LSN BeginningLsn,   // CLS_LSN
    CLS_LSN EndingLsn,   // CLS_LSN
    IntPtr TxfFileId,   // TXF_ID*
    IntPtr TxfLogContext   // void** out
);
<DllImport("txfw32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function TxfLogCreateFileReadContext(
    <MarshalAs(UnmanagedType.LPWStr)> LogPath As String,   ' LPCWSTR
    BeginningLsn As CLS_LSN,   ' CLS_LSN
    EndingLsn As CLS_LSN,   ' CLS_LSN
    TxfFileId As IntPtr,   ' TXF_ID*
    TxfLogContext As IntPtr   ' void** out
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
' LogPath : LPCWSTR
' BeginningLsn : CLS_LSN
' EndingLsn : CLS_LSN
' TxfFileId : TXF_ID*
' TxfLogContext : void** out
Declare PtrSafe Function TxfLogCreateFileReadContext Lib "txfw32" ( _
    ByVal LogPath As LongPtr, _
    ByVal BeginningLsn As LongPtr, _
    ByVal EndingLsn As LongPtr, _
    ByVal TxfFileId As LongPtr, _
    ByVal TxfLogContext As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

TxfLogCreateFileReadContext = ctypes.windll.txfw32.TxfLogCreateFileReadContext
TxfLogCreateFileReadContext.restype = wintypes.BOOL
TxfLogCreateFileReadContext.argtypes = [
    wintypes.LPCWSTR,  # LogPath : LPCWSTR
    CLS_LSN,  # BeginningLsn : CLS_LSN
    CLS_LSN,  # EndingLsn : CLS_LSN
    ctypes.c_void_p,  # TxfFileId : TXF_ID*
    ctypes.c_void_p,  # TxfLogContext : void** out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('txfw32.dll')
TxfLogCreateFileReadContext = Fiddle::Function.new(
  lib['TxfLogCreateFileReadContext'],
  [
    Fiddle::TYPE_VOIDP,  # LogPath : LPCWSTR
    Fiddle::TYPE_VOIDP,  # BeginningLsn : CLS_LSN
    Fiddle::TYPE_VOIDP,  # EndingLsn : CLS_LSN
    Fiddle::TYPE_VOIDP,  # TxfFileId : TXF_ID*
    Fiddle::TYPE_VOIDP,  # TxfLogContext : void** out
  ],
  Fiddle::TYPE_INT)
#[link(name = "txfw32")]
extern "system" {
    fn TxfLogCreateFileReadContext(
        LogPath: *const u16,  // LPCWSTR
        BeginningLsn: CLS_LSN,  // CLS_LSN
        EndingLsn: CLS_LSN,  // CLS_LSN
        TxfFileId: *mut TXF_ID,  // TXF_ID*
        TxfLogContext: *mut *mut ()  // void** out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("txfw32.dll", SetLastError = true)]
public static extern bool TxfLogCreateFileReadContext([MarshalAs(UnmanagedType.LPWStr)] string LogPath, CLS_LSN BeginningLsn, CLS_LSN EndingLsn, IntPtr TxfFileId, IntPtr TxfLogContext);
"@
$api = Add-Type -MemberDefinition $sig -Name 'txfw32_TxfLogCreateFileReadContext' -Namespace Win32 -PassThru
# $api::TxfLogCreateFileReadContext(LogPath, BeginningLsn, EndingLsn, TxfFileId, TxfLogContext)
#uselib "txfw32.dll"
#func global TxfLogCreateFileReadContext "TxfLogCreateFileReadContext" sptr, sptr, sptr, sptr, sptr
; TxfLogCreateFileReadContext LogPath, BeginningLsn, EndingLsn, varptr(TxfFileId), TxfLogContext   ; 戻り値は stat
; LogPath : LPCWSTR -> "sptr"
; BeginningLsn : CLS_LSN -> "sptr"
; EndingLsn : CLS_LSN -> "sptr"
; TxfFileId : TXF_ID* -> "sptr"
; TxfLogContext : void** out -> "sptr"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "txfw32.dll"
#cfunc global TxfLogCreateFileReadContext "TxfLogCreateFileReadContext" wstr, int, int, var, sptr
; res = TxfLogCreateFileReadContext(LogPath, BeginningLsn, EndingLsn, TxfFileId, TxfLogContext)
; LogPath : LPCWSTR -> "wstr"
; BeginningLsn : CLS_LSN -> "int"
; EndingLsn : CLS_LSN -> "int"
; TxfFileId : TXF_ID* -> "var"
; TxfLogContext : void** out -> "sptr"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL TxfLogCreateFileReadContext(LPCWSTR LogPath, CLS_LSN BeginningLsn, CLS_LSN EndingLsn, TXF_ID* TxfFileId, void** TxfLogContext)
#uselib "txfw32.dll"
#cfunc global TxfLogCreateFileReadContext "TxfLogCreateFileReadContext" wstr, int, int, var, intptr
; res = TxfLogCreateFileReadContext(LogPath, BeginningLsn, EndingLsn, TxfFileId, TxfLogContext)
; LogPath : LPCWSTR -> "wstr"
; BeginningLsn : CLS_LSN -> "int"
; EndingLsn : CLS_LSN -> "int"
; TxfFileId : TXF_ID* -> "var"
; TxfLogContext : void** out -> "intptr"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	txfw32 = windows.NewLazySystemDLL("txfw32.dll")
	procTxfLogCreateFileReadContext = txfw32.NewProc("TxfLogCreateFileReadContext")
)

// LogPath (LPCWSTR), BeginningLsn (CLS_LSN), EndingLsn (CLS_LSN), TxfFileId (TXF_ID*), TxfLogContext (void** out)
r1, _, err := procTxfLogCreateFileReadContext.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(LogPath))),
	uintptr(BeginningLsn),
	uintptr(EndingLsn),
	uintptr(TxfFileId),
	uintptr(TxfLogContext),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function TxfLogCreateFileReadContext(
  LogPath: PWideChar;   // LPCWSTR
  BeginningLsn: CLS_LSN;   // CLS_LSN
  EndingLsn: CLS_LSN;   // CLS_LSN
  TxfFileId: Pointer;   // TXF_ID*
  TxfLogContext: Pointer   // void** out
): BOOL; stdcall;
  external 'txfw32.dll' name 'TxfLogCreateFileReadContext';
result := DllCall("txfw32\TxfLogCreateFileReadContext"
    , "WStr", LogPath   ; LPCWSTR
    , "Ptr", BeginningLsn   ; CLS_LSN
    , "Ptr", EndingLsn   ; CLS_LSN
    , "Ptr", TxfFileId   ; TXF_ID*
    , "Ptr", TxfLogContext   ; void** out
    , "Int")   ; return: BOOL
●TxfLogCreateFileReadContext(LogPath, BeginningLsn, EndingLsn, TxfFileId, TxfLogContext) = DLL("txfw32.dll", "bool TxfLogCreateFileReadContext(char*, void*, void*, void*, void*)")
# 呼び出し: TxfLogCreateFileReadContext(LogPath, BeginningLsn, EndingLsn, TxfFileId, TxfLogContext)
# LogPath : LPCWSTR -> "char*"
# BeginningLsn : CLS_LSN -> "void*"
# EndingLsn : CLS_LSN -> "void*"
# TxfFileId : TXF_ID* -> "void*"
# TxfLogContext : void** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "txfw32" fn TxfLogCreateFileReadContext(
    LogPath: [*c]const u16, // LPCWSTR
    BeginningLsn: CLS_LSN, // CLS_LSN
    EndingLsn: CLS_LSN, // CLS_LSN
    TxfFileId: [*c]TXF_ID, // TXF_ID*
    TxfLogContext: ?*anyopaque // void** out
) callconv(std.os.windows.WINAPI) i32;
proc TxfLogCreateFileReadContext(
    LogPath: WideCString,  # LPCWSTR
    BeginningLsn: CLS_LSN,  # CLS_LSN
    EndingLsn: CLS_LSN,  # CLS_LSN
    TxfFileId: ptr TXF_ID,  # TXF_ID*
    TxfLogContext: pointer  # void** out
): int32 {.importc: "TxfLogCreateFileReadContext", stdcall, dynlib: "txfw32.dll".}
pragma(lib, "txfw32");
extern(Windows)
int TxfLogCreateFileReadContext(
    const(wchar)* LogPath,   // LPCWSTR
    CLS_LSN BeginningLsn,   // CLS_LSN
    CLS_LSN EndingLsn,   // CLS_LSN
    TXF_ID* TxfFileId,   // TXF_ID*
    void** TxfLogContext   // void** out
);
ccall((:TxfLogCreateFileReadContext, "txfw32.dll"), stdcall, Int32,
      (Cwstring, CLS_LSN, CLS_LSN, Ptr{TXF_ID}, Ptr{Cvoid}),
      LogPath, BeginningLsn, EndingLsn, TxfFileId, TxfLogContext)
# LogPath : LPCWSTR -> Cwstring
# BeginningLsn : CLS_LSN -> CLS_LSN
# EndingLsn : CLS_LSN -> CLS_LSN
# TxfFileId : TXF_ID* -> Ptr{TXF_ID}
# TxfLogContext : void** out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t TxfLogCreateFileReadContext(
    const uint16_t* LogPath,
    CLS_LSN BeginningLsn,
    CLS_LSN EndingLsn,
    void* TxfFileId,
    void** TxfLogContext);
]]
local txfw32 = ffi.load("txfw32")
-- txfw32.TxfLogCreateFileReadContext(LogPath, BeginningLsn, EndingLsn, TxfFileId, TxfLogContext)
-- LogPath : LPCWSTR
-- BeginningLsn : CLS_LSN
-- EndingLsn : CLS_LSN
-- TxfFileId : TXF_ID*
-- TxfLogContext : void** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('txfw32.dll');
const TxfLogCreateFileReadContext = lib.func('__stdcall', 'TxfLogCreateFileReadContext', 'int32_t', ['str16', 'CLS_LSN', 'CLS_LSN', 'void *', 'void *']);
// TxfLogCreateFileReadContext(LogPath, BeginningLsn, EndingLsn, TxfFileId, TxfLogContext)
// LogPath : LPCWSTR -> 'str16'
// BeginningLsn : CLS_LSN -> 'CLS_LSN'
// EndingLsn : CLS_LSN -> 'CLS_LSN'
// TxfFileId : TXF_ID* -> 'void *'
// TxfLogContext : void** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("txfw32.dll", {
  TxfLogCreateFileReadContext: { parameters: ["buffer", "buffer", "buffer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.TxfLogCreateFileReadContext(LogPath, BeginningLsn, EndingLsn, TxfFileId, TxfLogContext)
// LogPath : LPCWSTR -> "buffer"
// BeginningLsn : CLS_LSN -> "buffer"
// EndingLsn : CLS_LSN -> "buffer"
// TxfFileId : TXF_ID* -> "pointer"
// TxfLogContext : void** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t TxfLogCreateFileReadContext(
    const uint16_t* LogPath,
    CLS_LSN BeginningLsn,
    CLS_LSN EndingLsn,
    void* TxfFileId,
    void** TxfLogContext);
C, "txfw32.dll");
// $ffi->TxfLogCreateFileReadContext(LogPath, BeginningLsn, EndingLsn, TxfFileId, TxfLogContext);
// LogPath : LPCWSTR
// BeginningLsn : CLS_LSN
// EndingLsn : CLS_LSN
// TxfFileId : TXF_ID*
// TxfLogContext : 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 Txfw32 extends StdCallLibrary {
    Txfw32 INSTANCE = Native.load("txfw32", Txfw32.class);
    boolean TxfLogCreateFileReadContext(
        WString LogPath,   // LPCWSTR
        CLS_LSN /* extends Structure (by value) */ BeginningLsn,   // CLS_LSN
        CLS_LSN /* extends Structure (by value) */ EndingLsn,   // CLS_LSN
        Pointer TxfFileId,   // TXF_ID*
        Pointer TxfLogContext   // void** out
    );
}
@[Link("txfw32")]
lib Libtxfw32
  fun TxfLogCreateFileReadContext = TxfLogCreateFileReadContext(
    LogPath : UInt16*,   # LPCWSTR
    BeginningLsn : CLS_LSN,   # CLS_LSN
    EndingLsn : CLS_LSN,   # CLS_LSN
    TxfFileId : TXF_ID*,   # TXF_ID*
    TxfLogContext : 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 TxfLogCreateFileReadContextNative = Int32 Function(Pointer<Utf16>, CLS_LSN, CLS_LSN, Pointer<Void>, Pointer<Void>);
typedef TxfLogCreateFileReadContextDart = int Function(Pointer<Utf16>, int, int, Pointer<Void>, Pointer<Void>);
final TxfLogCreateFileReadContext = DynamicLibrary.open('txfw32.dll')
    .lookupFunction<TxfLogCreateFileReadContextNative, TxfLogCreateFileReadContextDart>('TxfLogCreateFileReadContext');
// LogPath : LPCWSTR -> Pointer<Utf16>
// BeginningLsn : CLS_LSN -> CLS_LSN
// EndingLsn : CLS_LSN -> CLS_LSN
// TxfFileId : TXF_ID* -> Pointer<Void>
// TxfLogContext : void** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function TxfLogCreateFileReadContext(
  LogPath: PWideChar;   // LPCWSTR
  BeginningLsn: CLS_LSN;   // CLS_LSN
  EndingLsn: CLS_LSN;   // CLS_LSN
  TxfFileId: Pointer;   // TXF_ID*
  TxfLogContext: Pointer   // void** out
): BOOL; stdcall;
  external 'txfw32.dll' name 'TxfLogCreateFileReadContext';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "TxfLogCreateFileReadContext"
  c_TxfLogCreateFileReadContext :: CWString -> CLS_LSN -> CLS_LSN -> Ptr () -> Ptr () -> IO CInt
-- LogPath : LPCWSTR -> CWString
-- BeginningLsn : CLS_LSN -> CLS_LSN
-- EndingLsn : CLS_LSN -> CLS_LSN
-- TxfFileId : TXF_ID* -> Ptr ()
-- TxfLogContext : void** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
-- ※値渡し構造体は GHC FFI で直接渡せません。Ptr で渡すラッパ(C側)経由にしてください。
open Ctypes
open Foreign

let txflogcreatefilereadcontext =
  foreign "TxfLogCreateFileReadContext"
    ((ptr uint16_t) @-> CLS_LSN @-> CLS_LSN @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* LogPath : LPCWSTR -> (ptr uint16_t) *)
(* BeginningLsn : CLS_LSN -> CLS_LSN *)
(* EndingLsn : CLS_LSN -> CLS_LSN *)
(* TxfFileId : TXF_ID* -> (ptr void) *)
(* TxfLogContext : void** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library txfw32 (t "txfw32.dll"))
(cffi:use-foreign-library txfw32)

(cffi:defcfun ("TxfLogCreateFileReadContext" txf-log-create-file-read-context :convention :stdcall) :int32
  (log-path (:string :encoding :utf-16le))   ; LPCWSTR
  (beginning-lsn (:struct cls-lsn))   ; CLS_LSN
  (ending-lsn (:struct cls-lsn))   ; CLS_LSN
  (txf-file-id :pointer)   ; TXF_ID*
  (txf-log-context :pointer))   ; void** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $TxfLogCreateFileReadContext = Win32::API::More->new('txfw32',
    'BOOL TxfLogCreateFileReadContext(LPCWSTR LogPath, LPVOID BeginningLsn, LPVOID EndingLsn, LPVOID TxfFileId, LPVOID TxfLogContext)');
# my $ret = $TxfLogCreateFileReadContext->Call($LogPath, $BeginningLsn, $EndingLsn, $TxfFileId, $TxfLogContext);
# LogPath : LPCWSTR -> LPCWSTR
# BeginningLsn : CLS_LSN -> LPVOID
# EndingLsn : CLS_LSN -> LPVOID
# TxfFileId : TXF_ID* -> LPVOID
# TxfLogContext : void** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

公式の関連項目
使用する型