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

CertDeleteCertificateFromStore

関数
証明書をストアから削除する。
DLLCRYPT32.dll呼出規約winapiSetLastErrorあり対応OSWindows XP 以降

シグネチャ

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

BOOL CertDeleteCertificateFromStore(
    const CERT_CONTEXT* pCertContext
);

パラメーター

名前方向
pCertContextCERT_CONTEXT*in

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL CertDeleteCertificateFromStore(
    const CERT_CONTEXT* pCertContext
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("CRYPT32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool CertDeleteCertificateFromStore(
    IntPtr pCertContext   // CERT_CONTEXT*
);
<DllImport("CRYPT32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function CertDeleteCertificateFromStore(
    pCertContext As IntPtr   ' CERT_CONTEXT*
) As Boolean
End Function
' pCertContext : CERT_CONTEXT*
Declare PtrSafe Function CertDeleteCertificateFromStore Lib "crypt32" ( _
    ByVal pCertContext As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CertDeleteCertificateFromStore = ctypes.windll.crypt32.CertDeleteCertificateFromStore
CertDeleteCertificateFromStore.restype = wintypes.BOOL
CertDeleteCertificateFromStore.argtypes = [
    ctypes.c_void_p,  # pCertContext : CERT_CONTEXT*
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('CRYPT32.dll')
CertDeleteCertificateFromStore = Fiddle::Function.new(
  lib['CertDeleteCertificateFromStore'],
  [
    Fiddle::TYPE_VOIDP,  # pCertContext : CERT_CONTEXT*
  ],
  Fiddle::TYPE_INT)
#[link(name = "crypt32")]
extern "system" {
    fn CertDeleteCertificateFromStore(
        pCertContext: *const CERT_CONTEXT  // CERT_CONTEXT*
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("CRYPT32.dll", SetLastError = true)]
public static extern bool CertDeleteCertificateFromStore(IntPtr pCertContext);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CRYPT32_CertDeleteCertificateFromStore' -Namespace Win32 -PassThru
# $api::CertDeleteCertificateFromStore(pCertContext)
#uselib "CRYPT32.dll"
#func global CertDeleteCertificateFromStore "CertDeleteCertificateFromStore" sptr
; CertDeleteCertificateFromStore varptr(pCertContext)   ; 戻り値は stat
; pCertContext : CERT_CONTEXT* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "CRYPT32.dll"
#cfunc global CertDeleteCertificateFromStore "CertDeleteCertificateFromStore" var
; res = CertDeleteCertificateFromStore(pCertContext)
; pCertContext : CERT_CONTEXT* -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL CertDeleteCertificateFromStore(CERT_CONTEXT* pCertContext)
#uselib "CRYPT32.dll"
#cfunc global CertDeleteCertificateFromStore "CertDeleteCertificateFromStore" var
; res = CertDeleteCertificateFromStore(pCertContext)
; pCertContext : CERT_CONTEXT* -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	crypt32 = windows.NewLazySystemDLL("CRYPT32.dll")
	procCertDeleteCertificateFromStore = crypt32.NewProc("CertDeleteCertificateFromStore")
)

// pCertContext (CERT_CONTEXT*)
r1, _, err := procCertDeleteCertificateFromStore.Call(
	uintptr(pCertContext),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function CertDeleteCertificateFromStore(
  pCertContext: Pointer   // CERT_CONTEXT*
): BOOL; stdcall;
  external 'CRYPT32.dll' name 'CertDeleteCertificateFromStore';
result := DllCall("CRYPT32\CertDeleteCertificateFromStore"
    , "Ptr", pCertContext   ; CERT_CONTEXT*
    , "Int")   ; return: BOOL
●CertDeleteCertificateFromStore(pCertContext) = DLL("CRYPT32.dll", "bool CertDeleteCertificateFromStore(void*)")
# 呼び出し: CertDeleteCertificateFromStore(pCertContext)
# pCertContext : CERT_CONTEXT* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。