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

JetReadFile

関数
外部バックアップで開いたファイルからデータを読み取る。
DLLESENT.dll呼出規約winapi

シグネチャ

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

INT JetReadFile(
    JET_HANDLE hfFile,
    void* pv,
    DWORD cb,
    DWORD* pcbActual   // optional
);

パラメーター

名前方向
hfFileJET_HANDLEin
pvvoid*out
cbDWORDin
pcbActualDWORD*outoptional

戻り値の型: INT

各言語での呼び出し定義

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

INT JetReadFile(
    JET_HANDLE hfFile,
    void* pv,
    DWORD cb,
    DWORD* pcbActual   // optional
);
[DllImport("ESENT.dll", ExactSpelling = true)]
static extern int JetReadFile(
    UIntPtr hfFile,   // JET_HANDLE
    IntPtr pv,   // void* out
    uint cb,   // DWORD
    IntPtr pcbActual   // DWORD* optional, out
);
<DllImport("ESENT.dll", ExactSpelling:=True)>
Public Shared Function JetReadFile(
    hfFile As UIntPtr,   ' JET_HANDLE
    pv As IntPtr,   ' void* out
    cb As UInteger,   ' DWORD
    pcbActual As IntPtr   ' DWORD* optional, out
) As Integer
End Function
' hfFile : JET_HANDLE
' pv : void* out
' cb : DWORD
' pcbActual : DWORD* optional, out
Declare PtrSafe Function JetReadFile Lib "esent" ( _
    ByVal hfFile As LongPtr, _
    ByVal pv As LongPtr, _
    ByVal cb As Long, _
    ByVal pcbActual As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

JetReadFile = ctypes.windll.esent.JetReadFile
JetReadFile.restype = ctypes.c_int
JetReadFile.argtypes = [
    ctypes.c_size_t,  # hfFile : JET_HANDLE
    ctypes.POINTER(None),  # pv : void* out
    wintypes.DWORD,  # cb : DWORD
    ctypes.POINTER(wintypes.DWORD),  # pcbActual : DWORD* optional, out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('ESENT.dll')
JetReadFile = Fiddle::Function.new(
  lib['JetReadFile'],
  [
    Fiddle::TYPE_UINTPTR_T,  # hfFile : JET_HANDLE
    Fiddle::TYPE_VOIDP,  # pv : void* out
    -Fiddle::TYPE_INT,  # cb : DWORD
    Fiddle::TYPE_VOIDP,  # pcbActual : DWORD* optional, out
  ],
  Fiddle::TYPE_INT)
#[link(name = "esent")]
extern "system" {
    fn JetReadFile(
        hfFile: usize,  // JET_HANDLE
        pv: *mut (),  // void* out
        cb: u32,  // DWORD
        pcbActual: *mut u32  // DWORD* optional, out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("ESENT.dll")]
public static extern int JetReadFile(UIntPtr hfFile, IntPtr pv, uint cb, IntPtr pcbActual);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ESENT_JetReadFile' -Namespace Win32 -PassThru
# $api::JetReadFile(hfFile, pv, cb, pcbActual)
#uselib "ESENT.dll"
#func global JetReadFile "JetReadFile" sptr, sptr, sptr, sptr
; JetReadFile hfFile, pv, cb, varptr(pcbActual)   ; 戻り値は stat
; hfFile : JET_HANDLE -> "sptr"
; pv : void* out -> "sptr"
; cb : DWORD -> "sptr"
; pcbActual : DWORD* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "ESENT.dll"
#cfunc global JetReadFile "JetReadFile" sptr, sptr, int, var
; res = JetReadFile(hfFile, pv, cb, pcbActual)
; hfFile : JET_HANDLE -> "sptr"
; pv : void* out -> "sptr"
; cb : DWORD -> "int"
; pcbActual : DWORD* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; INT JetReadFile(JET_HANDLE hfFile, void* pv, DWORD cb, DWORD* pcbActual)
#uselib "ESENT.dll"
#cfunc global JetReadFile "JetReadFile" intptr, intptr, int, var
; res = JetReadFile(hfFile, pv, cb, pcbActual)
; hfFile : JET_HANDLE -> "intptr"
; pv : void* out -> "intptr"
; cb : DWORD -> "int"
; pcbActual : DWORD* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	esent = windows.NewLazySystemDLL("ESENT.dll")
	procJetReadFile = esent.NewProc("JetReadFile")
)

// hfFile (JET_HANDLE), pv (void* out), cb (DWORD), pcbActual (DWORD* optional, out)
r1, _, err := procJetReadFile.Call(
	uintptr(hfFile),
	uintptr(pv),
	uintptr(cb),
	uintptr(pcbActual),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
function JetReadFile(
  hfFile: NativeUInt;   // JET_HANDLE
  pv: Pointer;   // void* out
  cb: DWORD;   // DWORD
  pcbActual: Pointer   // DWORD* optional, out
): Integer; stdcall;
  external 'ESENT.dll' name 'JetReadFile';
result := DllCall("ESENT\JetReadFile"
    , "UPtr", hfFile   ; JET_HANDLE
    , "Ptr", pv   ; void* out
    , "UInt", cb   ; DWORD
    , "Ptr", pcbActual   ; DWORD* optional, out
    , "Int")   ; return: INT
●JetReadFile(hfFile, pv, cb, pcbActual) = DLL("ESENT.dll", "int JetReadFile(int, void*, dword, void*)")
# 呼び出し: JetReadFile(hfFile, pv, cb, pcbActual)
# hfFile : JET_HANDLE -> "int"
# pv : void* out -> "void*"
# cb : DWORD -> "dword"
# pcbActual : DWORD* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。