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

CertSrvRestoreRegisterComplete

関数
証明書サービスの復元登録処理を完了させる。
DLLcertadm.dll呼出規約winapi対応OSwindowsserver2003

シグネチャ

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

HRESULT CertSrvRestoreRegisterComplete(
    void* hbc,
    HRESULT hrRestoreState
);

パラメーター

名前方向説明
hbcvoid*inoutCertSrvRestorePrepareWで取得したリストアコンテキストハンドル。
hrRestoreStateHRESULTinリストア処理の最終結果を示すHRESULT。成功はS_OKを指定する。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT CertSrvRestoreRegisterComplete(
    void* hbc,
    HRESULT hrRestoreState
);
[DllImport("certadm.dll", ExactSpelling = true)]
static extern int CertSrvRestoreRegisterComplete(
    IntPtr hbc,   // void* in/out
    int hrRestoreState   // HRESULT
);
<DllImport("certadm.dll", ExactSpelling:=True)>
Public Shared Function CertSrvRestoreRegisterComplete(
    hbc As IntPtr,   ' void* in/out
    hrRestoreState As Integer   ' HRESULT
) As Integer
End Function
' hbc : void* in/out
' hrRestoreState : HRESULT
Declare PtrSafe Function CertSrvRestoreRegisterComplete Lib "certadm" ( _
    ByVal hbc As LongPtr, _
    ByVal hrRestoreState As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CertSrvRestoreRegisterComplete = ctypes.windll.certadm.CertSrvRestoreRegisterComplete
CertSrvRestoreRegisterComplete.restype = ctypes.c_int
CertSrvRestoreRegisterComplete.argtypes = [
    ctypes.POINTER(None),  # hbc : void* in/out
    ctypes.c_int,  # hrRestoreState : HRESULT
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('certadm.dll')
CertSrvRestoreRegisterComplete = Fiddle::Function.new(
  lib['CertSrvRestoreRegisterComplete'],
  [
    Fiddle::TYPE_VOIDP,  # hbc : void* in/out
    Fiddle::TYPE_INT,  # hrRestoreState : HRESULT
  ],
  Fiddle::TYPE_INT)
#[link(name = "certadm")]
extern "system" {
    fn CertSrvRestoreRegisterComplete(
        hbc: *mut (),  // void* in/out
        hrRestoreState: i32  // HRESULT
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("certadm.dll")]
public static extern int CertSrvRestoreRegisterComplete(IntPtr hbc, int hrRestoreState);
"@
$api = Add-Type -MemberDefinition $sig -Name 'certadm_CertSrvRestoreRegisterComplete' -Namespace Win32 -PassThru
# $api::CertSrvRestoreRegisterComplete(hbc, hrRestoreState)
#uselib "certadm.dll"
#func global CertSrvRestoreRegisterComplete "CertSrvRestoreRegisterComplete" sptr, sptr
; CertSrvRestoreRegisterComplete hbc, hrRestoreState   ; 戻り値は stat
; hbc : void* in/out -> "sptr"
; hrRestoreState : HRESULT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "certadm.dll"
#cfunc global CertSrvRestoreRegisterComplete "CertSrvRestoreRegisterComplete" sptr, int
; res = CertSrvRestoreRegisterComplete(hbc, hrRestoreState)
; hbc : void* in/out -> "sptr"
; hrRestoreState : HRESULT -> "int"
; HRESULT CertSrvRestoreRegisterComplete(void* hbc, HRESULT hrRestoreState)
#uselib "certadm.dll"
#cfunc global CertSrvRestoreRegisterComplete "CertSrvRestoreRegisterComplete" intptr, int
; res = CertSrvRestoreRegisterComplete(hbc, hrRestoreState)
; hbc : void* in/out -> "intptr"
; hrRestoreState : HRESULT -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	certadm = windows.NewLazySystemDLL("certadm.dll")
	procCertSrvRestoreRegisterComplete = certadm.NewProc("CertSrvRestoreRegisterComplete")
)

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

extern "certadm" fn CertSrvRestoreRegisterComplete(
    hbc: ?*anyopaque, // void* in/out
    hrRestoreState: i32 // HRESULT
) callconv(std.os.windows.WINAPI) i32;
proc CertSrvRestoreRegisterComplete(
    hbc: pointer,  # void* in/out
    hrRestoreState: int32  # HRESULT
): int32 {.importc: "CertSrvRestoreRegisterComplete", stdcall, dynlib: "certadm.dll".}
pragma(lib, "certadm");
extern(Windows)
int CertSrvRestoreRegisterComplete(
    void* hbc,   // void* in/out
    int hrRestoreState   // HRESULT
);
ccall((:CertSrvRestoreRegisterComplete, "certadm.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Int32),
      hbc, hrRestoreState)
# hbc : void* in/out -> Ptr{Cvoid}
# hrRestoreState : HRESULT -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t CertSrvRestoreRegisterComplete(
    void* hbc,
    int32_t hrRestoreState);
]]
local certadm = ffi.load("certadm")
-- certadm.CertSrvRestoreRegisterComplete(hbc, hrRestoreState)
-- hbc : void* in/out
-- hrRestoreState : HRESULT
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('certadm.dll');
const CertSrvRestoreRegisterComplete = lib.func('__stdcall', 'CertSrvRestoreRegisterComplete', 'int32_t', ['void *', 'int32_t']);
// CertSrvRestoreRegisterComplete(hbc, hrRestoreState)
// hbc : void* in/out -> 'void *'
// hrRestoreState : HRESULT -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("certadm.dll", {
  CertSrvRestoreRegisterComplete: { parameters: ["pointer", "i32"], result: "i32" },
});
// lib.symbols.CertSrvRestoreRegisterComplete(hbc, hrRestoreState)
// hbc : void* in/out -> "pointer"
// hrRestoreState : HRESULT -> "i32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t CertSrvRestoreRegisterComplete(
    void* hbc,
    int32_t hrRestoreState);
C, "certadm.dll");
// $ffi->CertSrvRestoreRegisterComplete(hbc, hrRestoreState);
// hbc : void* in/out
// hrRestoreState : HRESULT
// 構造体/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 Certadm extends StdCallLibrary {
    Certadm INSTANCE = Native.load("certadm", Certadm.class);
    int CertSrvRestoreRegisterComplete(
        Pointer hbc,   // void* in/out
        int hrRestoreState   // HRESULT
    );
}
@[Link("certadm")]
lib Libcertadm
  fun CertSrvRestoreRegisterComplete = CertSrvRestoreRegisterComplete(
    hbc : Void*,   # void* in/out
    hrRestoreState : Int32   # HRESULT
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef CertSrvRestoreRegisterCompleteNative = Int32 Function(Pointer<Void>, Int32);
typedef CertSrvRestoreRegisterCompleteDart = int Function(Pointer<Void>, int);
final CertSrvRestoreRegisterComplete = DynamicLibrary.open('certadm.dll')
    .lookupFunction<CertSrvRestoreRegisterCompleteNative, CertSrvRestoreRegisterCompleteDart>('CertSrvRestoreRegisterComplete');
// hbc : void* in/out -> Pointer<Void>
// hrRestoreState : HRESULT -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function CertSrvRestoreRegisterComplete(
  hbc: Pointer;   // void* in/out
  hrRestoreState: Integer   // HRESULT
): Integer; stdcall;
  external 'certadm.dll' name 'CertSrvRestoreRegisterComplete';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "CertSrvRestoreRegisterComplete"
  c_CertSrvRestoreRegisterComplete :: Ptr () -> Int32 -> IO Int32
-- hbc : void* in/out -> Ptr ()
-- hrRestoreState : HRESULT -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let certsrvrestoreregistercomplete =
  foreign "CertSrvRestoreRegisterComplete"
    ((ptr void) @-> int32_t @-> returning int32_t)
(* hbc : void* in/out -> (ptr void) *)
(* hrRestoreState : HRESULT -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library certadm (t "certadm.dll"))
(cffi:use-foreign-library certadm)

(cffi:defcfun ("CertSrvRestoreRegisterComplete" cert-srv-restore-register-complete :convention :stdcall) :int32
  (hbc :pointer)   ; void* in/out
  (hr-restore-state :int32))   ; HRESULT
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $CertSrvRestoreRegisterComplete = Win32::API::More->new('certadm',
    'int CertSrvRestoreRegisterComplete(LPVOID hbc, int hrRestoreState)');
# my $ret = $CertSrvRestoreRegisterComplete->Call($hbc, $hrRestoreState);
# hbc : void* in/out -> LPVOID
# hrRestoreState : HRESULT -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。