ホーム › Security.Cryptography › CertAddCTLContextToStore
CertAddCTLContextToStore
関数CTLコンテキストをストアに追加する。
シグネチャ
// CRYPT32.dll
#include <windows.h>
BOOL CertAddCTLContextToStore(
HCERTSTORE hCertStore, // optional
CTL_CONTEXT* pCtlContext,
DWORD dwAddDisposition,
CTL_CONTEXT** ppStoreContext // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hCertStore | HCERTSTORE | inoptional |
| pCtlContext | CTL_CONTEXT* | in |
| dwAddDisposition | DWORD | in |
| ppStoreContext | CTL_CONTEXT** | outoptional |
戻り値の型: BOOL
各言語での呼び出し定義
// CRYPT32.dll
#include <windows.h>
BOOL CertAddCTLContextToStore(
HCERTSTORE hCertStore, // optional
CTL_CONTEXT* pCtlContext,
DWORD dwAddDisposition,
CTL_CONTEXT** ppStoreContext // optional
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("CRYPT32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool CertAddCTLContextToStore(
IntPtr hCertStore, // HCERTSTORE optional
IntPtr pCtlContext, // CTL_CONTEXT*
uint dwAddDisposition, // DWORD
IntPtr ppStoreContext // CTL_CONTEXT** optional, out
);<DllImport("CRYPT32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function CertAddCTLContextToStore(
hCertStore As IntPtr, ' HCERTSTORE optional
pCtlContext As IntPtr, ' CTL_CONTEXT*
dwAddDisposition As UInteger, ' DWORD
ppStoreContext As IntPtr ' CTL_CONTEXT** optional, out
) As Boolean
End Function' hCertStore : HCERTSTORE optional
' pCtlContext : CTL_CONTEXT*
' dwAddDisposition : DWORD
' ppStoreContext : CTL_CONTEXT** optional, out
Declare PtrSafe Function CertAddCTLContextToStore Lib "crypt32" ( _
ByVal hCertStore As LongPtr, _
ByVal pCtlContext As LongPtr, _
ByVal dwAddDisposition As Long, _
ByVal ppStoreContext As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CertAddCTLContextToStore = ctypes.windll.crypt32.CertAddCTLContextToStore
CertAddCTLContextToStore.restype = wintypes.BOOL
CertAddCTLContextToStore.argtypes = [
wintypes.HANDLE, # hCertStore : HCERTSTORE optional
ctypes.c_void_p, # pCtlContext : CTL_CONTEXT*
wintypes.DWORD, # dwAddDisposition : DWORD
ctypes.c_void_p, # ppStoreContext : CTL_CONTEXT** optional, out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('CRYPT32.dll')
CertAddCTLContextToStore = Fiddle::Function.new(
lib['CertAddCTLContextToStore'],
[
Fiddle::TYPE_VOIDP, # hCertStore : HCERTSTORE optional
Fiddle::TYPE_VOIDP, # pCtlContext : CTL_CONTEXT*
-Fiddle::TYPE_INT, # dwAddDisposition : DWORD
Fiddle::TYPE_VOIDP, # ppStoreContext : CTL_CONTEXT** optional, out
],
Fiddle::TYPE_INT)#[link(name = "crypt32")]
extern "system" {
fn CertAddCTLContextToStore(
hCertStore: *mut core::ffi::c_void, // HCERTSTORE optional
pCtlContext: *mut CTL_CONTEXT, // CTL_CONTEXT*
dwAddDisposition: u32, // DWORD
ppStoreContext: *mut *mut CTL_CONTEXT // CTL_CONTEXT** optional, out
) -> 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 CertAddCTLContextToStore(IntPtr hCertStore, IntPtr pCtlContext, uint dwAddDisposition, IntPtr ppStoreContext);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CRYPT32_CertAddCTLContextToStore' -Namespace Win32 -PassThru
# $api::CertAddCTLContextToStore(hCertStore, pCtlContext, dwAddDisposition, ppStoreContext)#uselib "CRYPT32.dll"
#func global CertAddCTLContextToStore "CertAddCTLContextToStore" sptr, sptr, sptr, sptr
; CertAddCTLContextToStore hCertStore, varptr(pCtlContext), dwAddDisposition, varptr(ppStoreContext) ; 戻り値は stat
; hCertStore : HCERTSTORE optional -> "sptr"
; pCtlContext : CTL_CONTEXT* -> "sptr"
; dwAddDisposition : DWORD -> "sptr"
; ppStoreContext : CTL_CONTEXT** optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "CRYPT32.dll" #cfunc global CertAddCTLContextToStore "CertAddCTLContextToStore" sptr, var, int, var ; res = CertAddCTLContextToStore(hCertStore, pCtlContext, dwAddDisposition, ppStoreContext) ; hCertStore : HCERTSTORE optional -> "sptr" ; pCtlContext : CTL_CONTEXT* -> "var" ; dwAddDisposition : DWORD -> "int" ; ppStoreContext : CTL_CONTEXT** optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "CRYPT32.dll" #cfunc global CertAddCTLContextToStore "CertAddCTLContextToStore" sptr, sptr, int, sptr ; res = CertAddCTLContextToStore(hCertStore, varptr(pCtlContext), dwAddDisposition, varptr(ppStoreContext)) ; hCertStore : HCERTSTORE optional -> "sptr" ; pCtlContext : CTL_CONTEXT* -> "sptr" ; dwAddDisposition : DWORD -> "int" ; ppStoreContext : CTL_CONTEXT** optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL CertAddCTLContextToStore(HCERTSTORE hCertStore, CTL_CONTEXT* pCtlContext, DWORD dwAddDisposition, CTL_CONTEXT** ppStoreContext) #uselib "CRYPT32.dll" #cfunc global CertAddCTLContextToStore "CertAddCTLContextToStore" intptr, var, int, var ; res = CertAddCTLContextToStore(hCertStore, pCtlContext, dwAddDisposition, ppStoreContext) ; hCertStore : HCERTSTORE optional -> "intptr" ; pCtlContext : CTL_CONTEXT* -> "var" ; dwAddDisposition : DWORD -> "int" ; ppStoreContext : CTL_CONTEXT** optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL CertAddCTLContextToStore(HCERTSTORE hCertStore, CTL_CONTEXT* pCtlContext, DWORD dwAddDisposition, CTL_CONTEXT** ppStoreContext) #uselib "CRYPT32.dll" #cfunc global CertAddCTLContextToStore "CertAddCTLContextToStore" intptr, intptr, int, intptr ; res = CertAddCTLContextToStore(hCertStore, varptr(pCtlContext), dwAddDisposition, varptr(ppStoreContext)) ; hCertStore : HCERTSTORE optional -> "intptr" ; pCtlContext : CTL_CONTEXT* -> "intptr" ; dwAddDisposition : DWORD -> "int" ; ppStoreContext : CTL_CONTEXT** optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
crypt32 = windows.NewLazySystemDLL("CRYPT32.dll")
procCertAddCTLContextToStore = crypt32.NewProc("CertAddCTLContextToStore")
)
// hCertStore (HCERTSTORE optional), pCtlContext (CTL_CONTEXT*), dwAddDisposition (DWORD), ppStoreContext (CTL_CONTEXT** optional, out)
r1, _, err := procCertAddCTLContextToStore.Call(
uintptr(hCertStore),
uintptr(pCtlContext),
uintptr(dwAddDisposition),
uintptr(ppStoreContext),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction CertAddCTLContextToStore(
hCertStore: THandle; // HCERTSTORE optional
pCtlContext: Pointer; // CTL_CONTEXT*
dwAddDisposition: DWORD; // DWORD
ppStoreContext: Pointer // CTL_CONTEXT** optional, out
): BOOL; stdcall;
external 'CRYPT32.dll' name 'CertAddCTLContextToStore';result := DllCall("CRYPT32\CertAddCTLContextToStore"
, "Ptr", hCertStore ; HCERTSTORE optional
, "Ptr", pCtlContext ; CTL_CONTEXT*
, "UInt", dwAddDisposition ; DWORD
, "Ptr", ppStoreContext ; CTL_CONTEXT** optional, out
, "Int") ; return: BOOL●CertAddCTLContextToStore(hCertStore, pCtlContext, dwAddDisposition, ppStoreContext) = DLL("CRYPT32.dll", "bool CertAddCTLContextToStore(void*, void*, dword, void*)")
# 呼び出し: CertAddCTLContextToStore(hCertStore, pCtlContext, dwAddDisposition, ppStoreContext)
# hCertStore : HCERTSTORE optional -> "void*"
# pCtlContext : CTL_CONTEXT* -> "void*"
# dwAddDisposition : DWORD -> "dword"
# ppStoreContext : CTL_CONTEXT** optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。