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

JetRestoreA

関数
バックアップからデータベースを復元する(ANSI版)。
DLLESENT.dll文字セットANSI (-A)呼出規約winapi

シグネチャ

// ESENT.dll  (ANSI / -A)
#include <windows.h>

INT JetRestoreA(
    CHAR* szSource,
    JET_PFNSTATUS pfn   // optional
);

パラメーター

名前方向説明
szSourceCHAR*in復元元バックアップファイルが格納されたディレクトリのパスを指す終端付きANSI文字列ポインタ。
pfnJET_PFNSTATUSinoptional進捗通知を受け取るステータスコールバック関数(JET_PFNSTATUS)。NULL可。

戻り値の型: INT

各言語での呼び出し定義

// ESENT.dll  (ANSI / -A)
#include <windows.h>

INT JetRestoreA(
    CHAR* szSource,
    JET_PFNSTATUS pfn   // optional
);
[DllImport("ESENT.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern int JetRestoreA(
    IntPtr szSource,   // CHAR*
    IntPtr pfn   // JET_PFNSTATUS optional
);
<DllImport("ESENT.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function JetRestoreA(
    szSource As IntPtr,   ' CHAR*
    pfn As IntPtr   ' JET_PFNSTATUS optional
) As Integer
End Function
' szSource : CHAR*
' pfn : JET_PFNSTATUS optional
Declare PtrSafe Function JetRestoreA Lib "esent" ( _
    ByVal szSource As LongPtr, _
    ByVal pfn As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

JetRestoreA = ctypes.windll.esent.JetRestoreA
JetRestoreA.restype = ctypes.c_int
JetRestoreA.argtypes = [
    ctypes.POINTER(ctypes.c_byte),  # szSource : CHAR*
    ctypes.c_void_p,  # pfn : JET_PFNSTATUS optional
]
require 'fiddle'
require 'fiddle/import'

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

var (
	esent = windows.NewLazySystemDLL("ESENT.dll")
	procJetRestoreA = esent.NewProc("JetRestoreA")
)

// szSource (CHAR*), pfn (JET_PFNSTATUS optional)
r1, _, err := procJetRestoreA.Call(
	uintptr(szSource),
	uintptr(pfn),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
function JetRestoreA(
  szSource: Pointer;   // CHAR*
  pfn: Pointer   // JET_PFNSTATUS optional
): Integer; stdcall;
  external 'ESENT.dll' name 'JetRestoreA';
result := DllCall("ESENT\JetRestoreA"
    , "Ptr", szSource   ; CHAR*
    , "Ptr", pfn   ; JET_PFNSTATUS optional
    , "Int")   ; return: INT
●JetRestoreA(szSource, pfn) = DLL("ESENT.dll", "int JetRestoreA(void*, void*)")
# 呼び出し: JetRestoreA(szSource, pfn)
# szSource : CHAR* -> "void*"
# pfn : JET_PFNSTATUS optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "esent" fn JetRestoreA(
    szSource: [*c]i8, // CHAR*
    pfn: ?*anyopaque // JET_PFNSTATUS optional
) callconv(std.os.windows.WINAPI) i32;
proc JetRestoreA(
    szSource: ptr int8,  # CHAR*
    pfn: pointer  # JET_PFNSTATUS optional
): int32 {.importc: "JetRestoreA", stdcall, dynlib: "ESENT.dll".}
pragma(lib, "esent");
extern(Windows)
int JetRestoreA(
    byte* szSource,   // CHAR*
    void* pfn   // JET_PFNSTATUS optional
);
ccall((:JetRestoreA, "ESENT.dll"), stdcall, Int32,
      (Ptr{Int8}, Ptr{Cvoid}),
      szSource, pfn)
# szSource : CHAR* -> Ptr{Int8}
# pfn : JET_PFNSTATUS optional -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t JetRestoreA(
    int8_t* szSource,
    void* pfn);
]]
local esent = ffi.load("esent")
-- esent.JetRestoreA(szSource, pfn)
-- szSource : CHAR*
-- pfn : JET_PFNSTATUS optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('ESENT.dll');
const JetRestoreA = lib.func('__stdcall', 'JetRestoreA', 'int32_t', ['int8_t *', 'void *']);
// JetRestoreA(szSource, pfn)
// szSource : CHAR* -> 'int8_t *'
// pfn : JET_PFNSTATUS optional -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
// コールバック(関数ポインタ)は koffi.proto/koffi.register で型を定義して渡す(素の void* では JS 関数を渡せない)。
const lib = Deno.dlopen("ESENT.dll", {
  JetRestoreA: { parameters: ["pointer", "pointer"], result: "i32" },
});
// lib.symbols.JetRestoreA(szSource, pfn)
// szSource : CHAR* -> "pointer"
// pfn : JET_PFNSTATUS optional -> "pointer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t JetRestoreA(
    int8_t* szSource,
    void* pfn);
C, "ESENT.dll");
// $ffi->JetRestoreA(szSource, pfn);
// szSource : CHAR*
// pfn : JET_PFNSTATUS optional
// 構造体/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 Esent extends StdCallLibrary {
    Esent INSTANCE = Native.load("esent", Esent.class, W32APIOptions.ASCII_OPTIONS);
    int JetRestoreA(
        byte[] szSource,   // CHAR*
        Callback pfn   // JET_PFNSTATUS optional
    );
}
@[Link("esent")]
lib LibESENT
  fun JetRestoreA = JetRestoreA(
    szSource : Int8*,   # CHAR*
    pfn : Void*   # JET_PFNSTATUS optional
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef JetRestoreANative = Int32 Function(Pointer<Int8>, Pointer<Void>);
typedef JetRestoreADart = int Function(Pointer<Int8>, Pointer<Void>);
final JetRestoreA = DynamicLibrary.open('ESENT.dll')
    .lookupFunction<JetRestoreANative, JetRestoreADart>('JetRestoreA');
// szSource : CHAR* -> Pointer<Int8>
// pfn : JET_PFNSTATUS optional -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function JetRestoreA(
  szSource: Pointer;   // CHAR*
  pfn: Pointer   // JET_PFNSTATUS optional
): Integer; stdcall;
  external 'ESENT.dll' name 'JetRestoreA';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "JetRestoreA"
  c_JetRestoreA :: Ptr Int8 -> Ptr () -> IO Int32
-- szSource : CHAR* -> Ptr Int8
-- pfn : JET_PFNSTATUS optional -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let jetrestorea =
  foreign "JetRestoreA"
    ((ptr int8_t) @-> (ptr void) @-> returning int32_t)
(* szSource : CHAR* -> (ptr int8_t) *)
(* pfn : JET_PFNSTATUS optional -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library esent (t "ESENT.dll"))
(cffi:use-foreign-library esent)

(cffi:defcfun ("JetRestoreA" jet-restore-a :convention :stdcall) :int32
  (sz-source :pointer)   ; CHAR*
  (pfn :pointer))   ; JET_PFNSTATUS optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $JetRestoreA = Win32::API::More->new('ESENT',
    'int JetRestoreA(LPVOID szSource, LPVOID pfn)');
# my $ret = $JetRestoreA->Call($szSource, $pfn);
# szSource : CHAR* -> LPVOID
# pfn : JET_PFNSTATUS optional -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# コールバック(関数ポインタ)は Perl sub を直接渡せません。Win32::API::Callback を使用してください。

関連項目

文字セット違い
類似 API
使用する型