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

CertDuplicateCTLContext

関数
CTLコンテキストを複製して参照を増やす。
DLLCRYPT32.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

CTL_CONTEXT* CertDuplicateCTLContext(
    CTL_CONTEXT* pCtlContext   // optional
);

パラメーター

名前方向
pCtlContextCTL_CONTEXT*inoptional

戻り値の型: CTL_CONTEXT*

各言語での呼び出し定義

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

CTL_CONTEXT* CertDuplicateCTLContext(
    CTL_CONTEXT* pCtlContext   // optional
);
[DllImport("CRYPT32.dll", ExactSpelling = true)]
static extern IntPtr CertDuplicateCTLContext(
    IntPtr pCtlContext   // CTL_CONTEXT* optional
);
<DllImport("CRYPT32.dll", ExactSpelling:=True)>
Public Shared Function CertDuplicateCTLContext(
    pCtlContext As IntPtr   ' CTL_CONTEXT* optional
) As IntPtr
End Function
' pCtlContext : CTL_CONTEXT* optional
Declare PtrSafe Function CertDuplicateCTLContext Lib "crypt32" ( _
    ByVal pCtlContext As LongPtr) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CertDuplicateCTLContext = ctypes.windll.crypt32.CertDuplicateCTLContext
CertDuplicateCTLContext.restype = ctypes.c_void_p
CertDuplicateCTLContext.argtypes = [
    ctypes.c_void_p,  # pCtlContext : CTL_CONTEXT* optional
]
require 'fiddle'
require 'fiddle/import'

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

var (
	crypt32 = windows.NewLazySystemDLL("CRYPT32.dll")
	procCertDuplicateCTLContext = crypt32.NewProc("CertDuplicateCTLContext")
)

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