Win32 API 日本語リファレンス
ホームSecurity.Cryptography.Certificates › CertSrvRestoreRegisterW

CertSrvRestoreRegisterW

関数
復元するログファイルやマッピング情報を登録する。
DLLcertadm.dll呼出規約winapi対応OSwindowsserver2003

シグネチャ

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

HRESULT CertSrvRestoreRegisterW(
    void* hbc,
    LPCWSTR pwszCheckPointFilePath,
    LPCWSTR pwszLogPath,
    CSEDB_RSTMAPW* rgrstmap,
    INT crstmap,
    LPCWSTR pwszBackupLogPath,
    DWORD genLow,
    DWORD genHigh
);

パラメーター

名前方向説明
hbcvoid*inoutCertSrvRestorePrepareWで取得したリストアコンテキストハンドル。
pwszCheckPointFilePathLPCWSTRinチェックポイントファイルの配置パス。NULL終端のワイド文字列で指定する。
pwszLogPathLPCWSTRinログファイルの配置パス。NULL終端のワイド文字列で指定する。
rgrstmapCSEDB_RSTMAPW*inoutリストア先マッピングを定義するCSEDB_RSTMAPW構造体の配列。
crstmapINTinrgrstmap配列に含まれるマッピング要素の個数。
pwszBackupLogPathLPCWSTRinバックアップログの配置パス。NULL終端のワイド文字列で指定する。
genLowDWORDinリストア対象ログ世代の下限値。
genHighDWORDinリストア対象ログ世代の上限値。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT CertSrvRestoreRegisterW(
    void* hbc,
    LPCWSTR pwszCheckPointFilePath,
    LPCWSTR pwszLogPath,
    CSEDB_RSTMAPW* rgrstmap,
    INT crstmap,
    LPCWSTR pwszBackupLogPath,
    DWORD genLow,
    DWORD genHigh
);
[DllImport("certadm.dll", ExactSpelling = true)]
static extern int CertSrvRestoreRegisterW(
    IntPtr hbc,   // void* in/out
    [MarshalAs(UnmanagedType.LPWStr)] string pwszCheckPointFilePath,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string pwszLogPath,   // LPCWSTR
    IntPtr rgrstmap,   // CSEDB_RSTMAPW* in/out
    int crstmap,   // INT
    [MarshalAs(UnmanagedType.LPWStr)] string pwszBackupLogPath,   // LPCWSTR
    uint genLow,   // DWORD
    uint genHigh   // DWORD
);
<DllImport("certadm.dll", ExactSpelling:=True)>
Public Shared Function CertSrvRestoreRegisterW(
    hbc As IntPtr,   ' void* in/out
    <MarshalAs(UnmanagedType.LPWStr)> pwszCheckPointFilePath As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> pwszLogPath As String,   ' LPCWSTR
    rgrstmap As IntPtr,   ' CSEDB_RSTMAPW* in/out
    crstmap As Integer,   ' INT
    <MarshalAs(UnmanagedType.LPWStr)> pwszBackupLogPath As String,   ' LPCWSTR
    genLow As UInteger,   ' DWORD
    genHigh As UInteger   ' DWORD
) As Integer
End Function
' hbc : void* in/out
' pwszCheckPointFilePath : LPCWSTR
' pwszLogPath : LPCWSTR
' rgrstmap : CSEDB_RSTMAPW* in/out
' crstmap : INT
' pwszBackupLogPath : LPCWSTR
' genLow : DWORD
' genHigh : DWORD
Declare PtrSafe Function CertSrvRestoreRegisterW Lib "certadm" ( _
    ByVal hbc As LongPtr, _
    ByVal pwszCheckPointFilePath As LongPtr, _
    ByVal pwszLogPath As LongPtr, _
    ByVal rgrstmap As LongPtr, _
    ByVal crstmap As Long, _
    ByVal pwszBackupLogPath As LongPtr, _
    ByVal genLow As Long, _
    ByVal genHigh As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CertSrvRestoreRegisterW = ctypes.windll.certadm.CertSrvRestoreRegisterW
CertSrvRestoreRegisterW.restype = ctypes.c_int
CertSrvRestoreRegisterW.argtypes = [
    ctypes.POINTER(None),  # hbc : void* in/out
    wintypes.LPCWSTR,  # pwszCheckPointFilePath : LPCWSTR
    wintypes.LPCWSTR,  # pwszLogPath : LPCWSTR
    ctypes.c_void_p,  # rgrstmap : CSEDB_RSTMAPW* in/out
    ctypes.c_int,  # crstmap : INT
    wintypes.LPCWSTR,  # pwszBackupLogPath : LPCWSTR
    wintypes.DWORD,  # genLow : DWORD
    wintypes.DWORD,  # genHigh : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('certadm.dll')
CertSrvRestoreRegisterW = Fiddle::Function.new(
  lib['CertSrvRestoreRegisterW'],
  [
    Fiddle::TYPE_VOIDP,  # hbc : void* in/out
    Fiddle::TYPE_VOIDP,  # pwszCheckPointFilePath : LPCWSTR
    Fiddle::TYPE_VOIDP,  # pwszLogPath : LPCWSTR
    Fiddle::TYPE_VOIDP,  # rgrstmap : CSEDB_RSTMAPW* in/out
    Fiddle::TYPE_INT,  # crstmap : INT
    Fiddle::TYPE_VOIDP,  # pwszBackupLogPath : LPCWSTR
    -Fiddle::TYPE_INT,  # genLow : DWORD
    -Fiddle::TYPE_INT,  # genHigh : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "certadm")]
extern "system" {
    fn CertSrvRestoreRegisterW(
        hbc: *mut (),  // void* in/out
        pwszCheckPointFilePath: *const u16,  // LPCWSTR
        pwszLogPath: *const u16,  // LPCWSTR
        rgrstmap: *mut CSEDB_RSTMAPW,  // CSEDB_RSTMAPW* in/out
        crstmap: i32,  // INT
        pwszBackupLogPath: *const u16,  // LPCWSTR
        genLow: u32,  // DWORD
        genHigh: u32  // DWORD
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("certadm.dll")]
public static extern int CertSrvRestoreRegisterW(IntPtr hbc, [MarshalAs(UnmanagedType.LPWStr)] string pwszCheckPointFilePath, [MarshalAs(UnmanagedType.LPWStr)] string pwszLogPath, IntPtr rgrstmap, int crstmap, [MarshalAs(UnmanagedType.LPWStr)] string pwszBackupLogPath, uint genLow, uint genHigh);
"@
$api = Add-Type -MemberDefinition $sig -Name 'certadm_CertSrvRestoreRegisterW' -Namespace Win32 -PassThru
# $api::CertSrvRestoreRegisterW(hbc, pwszCheckPointFilePath, pwszLogPath, rgrstmap, crstmap, pwszBackupLogPath, genLow, genHigh)
#uselib "certadm.dll"
#func global CertSrvRestoreRegisterW "CertSrvRestoreRegisterW" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; CertSrvRestoreRegisterW hbc, pwszCheckPointFilePath, pwszLogPath, varptr(rgrstmap), crstmap, pwszBackupLogPath, genLow, genHigh   ; 戻り値は stat
; hbc : void* in/out -> "sptr"
; pwszCheckPointFilePath : LPCWSTR -> "sptr"
; pwszLogPath : LPCWSTR -> "sptr"
; rgrstmap : CSEDB_RSTMAPW* in/out -> "sptr"
; crstmap : INT -> "sptr"
; pwszBackupLogPath : LPCWSTR -> "sptr"
; genLow : DWORD -> "sptr"
; genHigh : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "certadm.dll"
#cfunc global CertSrvRestoreRegisterW "CertSrvRestoreRegisterW" sptr, wstr, wstr, var, int, wstr, int, int
; res = CertSrvRestoreRegisterW(hbc, pwszCheckPointFilePath, pwszLogPath, rgrstmap, crstmap, pwszBackupLogPath, genLow, genHigh)
; hbc : void* in/out -> "sptr"
; pwszCheckPointFilePath : LPCWSTR -> "wstr"
; pwszLogPath : LPCWSTR -> "wstr"
; rgrstmap : CSEDB_RSTMAPW* in/out -> "var"
; crstmap : INT -> "int"
; pwszBackupLogPath : LPCWSTR -> "wstr"
; genLow : DWORD -> "int"
; genHigh : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT CertSrvRestoreRegisterW(void* hbc, LPCWSTR pwszCheckPointFilePath, LPCWSTR pwszLogPath, CSEDB_RSTMAPW* rgrstmap, INT crstmap, LPCWSTR pwszBackupLogPath, DWORD genLow, DWORD genHigh)
#uselib "certadm.dll"
#cfunc global CertSrvRestoreRegisterW "CertSrvRestoreRegisterW" intptr, wstr, wstr, var, int, wstr, int, int
; res = CertSrvRestoreRegisterW(hbc, pwszCheckPointFilePath, pwszLogPath, rgrstmap, crstmap, pwszBackupLogPath, genLow, genHigh)
; hbc : void* in/out -> "intptr"
; pwszCheckPointFilePath : LPCWSTR -> "wstr"
; pwszLogPath : LPCWSTR -> "wstr"
; rgrstmap : CSEDB_RSTMAPW* in/out -> "var"
; crstmap : INT -> "int"
; pwszBackupLogPath : LPCWSTR -> "wstr"
; genLow : DWORD -> "int"
; genHigh : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	certadm = windows.NewLazySystemDLL("certadm.dll")
	procCertSrvRestoreRegisterW = certadm.NewProc("CertSrvRestoreRegisterW")
)

// hbc (void* in/out), pwszCheckPointFilePath (LPCWSTR), pwszLogPath (LPCWSTR), rgrstmap (CSEDB_RSTMAPW* in/out), crstmap (INT), pwszBackupLogPath (LPCWSTR), genLow (DWORD), genHigh (DWORD)
r1, _, err := procCertSrvRestoreRegisterW.Call(
	uintptr(hbc),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwszCheckPointFilePath))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwszLogPath))),
	uintptr(rgrstmap),
	uintptr(crstmap),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwszBackupLogPath))),
	uintptr(genLow),
	uintptr(genHigh),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function CertSrvRestoreRegisterW(
  hbc: Pointer;   // void* in/out
  pwszCheckPointFilePath: PWideChar;   // LPCWSTR
  pwszLogPath: PWideChar;   // LPCWSTR
  rgrstmap: Pointer;   // CSEDB_RSTMAPW* in/out
  crstmap: Integer;   // INT
  pwszBackupLogPath: PWideChar;   // LPCWSTR
  genLow: DWORD;   // DWORD
  genHigh: DWORD   // DWORD
): Integer; stdcall;
  external 'certadm.dll' name 'CertSrvRestoreRegisterW';
result := DllCall("certadm\CertSrvRestoreRegisterW"
    , "Ptr", hbc   ; void* in/out
    , "WStr", pwszCheckPointFilePath   ; LPCWSTR
    , "WStr", pwszLogPath   ; LPCWSTR
    , "Ptr", rgrstmap   ; CSEDB_RSTMAPW* in/out
    , "Int", crstmap   ; INT
    , "WStr", pwszBackupLogPath   ; LPCWSTR
    , "UInt", genLow   ; DWORD
    , "UInt", genHigh   ; DWORD
    , "Int")   ; return: HRESULT
●CertSrvRestoreRegisterW(hbc, pwszCheckPointFilePath, pwszLogPath, rgrstmap, crstmap, pwszBackupLogPath, genLow, genHigh) = DLL("certadm.dll", "int CertSrvRestoreRegisterW(void*, char*, char*, void*, int, char*, dword, dword)")
# 呼び出し: CertSrvRestoreRegisterW(hbc, pwszCheckPointFilePath, pwszLogPath, rgrstmap, crstmap, pwszBackupLogPath, genLow, genHigh)
# hbc : void* in/out -> "void*"
# pwszCheckPointFilePath : LPCWSTR -> "char*"
# pwszLogPath : LPCWSTR -> "char*"
# rgrstmap : CSEDB_RSTMAPW* in/out -> "void*"
# crstmap : INT -> "int"
# pwszBackupLogPath : LPCWSTR -> "char*"
# genLow : DWORD -> "dword"
# genHigh : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。