ホーム › Security.Cryptography.Certificates › PstAcquirePrivateKey
PstAcquirePrivateKey
関数指定した証明書に対応する秘密鍵を取得する。
シグネチャ
// certpoleng.dll
#include <windows.h>
NTSTATUS PstAcquirePrivateKey(
const CERT_CONTEXT* pCert
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pCert | CERT_CONTEXT* | in |
戻り値の型: NTSTATUS
各言語での呼び出し定義
// certpoleng.dll
#include <windows.h>
NTSTATUS PstAcquirePrivateKey(
const CERT_CONTEXT* pCert
);[DllImport("certpoleng.dll", ExactSpelling = true)]
static extern int PstAcquirePrivateKey(
IntPtr pCert // CERT_CONTEXT*
);<DllImport("certpoleng.dll", ExactSpelling:=True)>
Public Shared Function PstAcquirePrivateKey(
pCert As IntPtr ' CERT_CONTEXT*
) As Integer
End Function' pCert : CERT_CONTEXT*
Declare PtrSafe Function PstAcquirePrivateKey Lib "certpoleng" ( _
ByVal pCert As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
PstAcquirePrivateKey = ctypes.windll.certpoleng.PstAcquirePrivateKey
PstAcquirePrivateKey.restype = ctypes.c_int
PstAcquirePrivateKey.argtypes = [
ctypes.c_void_p, # pCert : CERT_CONTEXT*
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('certpoleng.dll')
PstAcquirePrivateKey = Fiddle::Function.new(
lib['PstAcquirePrivateKey'],
[
Fiddle::TYPE_VOIDP, # pCert : CERT_CONTEXT*
],
Fiddle::TYPE_INT)#[link(name = "certpoleng")]
extern "system" {
fn PstAcquirePrivateKey(
pCert: *const CERT_CONTEXT // CERT_CONTEXT*
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("certpoleng.dll")]
public static extern int PstAcquirePrivateKey(IntPtr pCert);
"@
$api = Add-Type -MemberDefinition $sig -Name 'certpoleng_PstAcquirePrivateKey' -Namespace Win32 -PassThru
# $api::PstAcquirePrivateKey(pCert)#uselib "certpoleng.dll"
#func global PstAcquirePrivateKey "PstAcquirePrivateKey" sptr
; PstAcquirePrivateKey varptr(pCert) ; 戻り値は stat
; pCert : CERT_CONTEXT* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "certpoleng.dll" #cfunc global PstAcquirePrivateKey "PstAcquirePrivateKey" var ; res = PstAcquirePrivateKey(pCert) ; pCert : CERT_CONTEXT* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "certpoleng.dll" #cfunc global PstAcquirePrivateKey "PstAcquirePrivateKey" sptr ; res = PstAcquirePrivateKey(varptr(pCert)) ; pCert : CERT_CONTEXT* -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; NTSTATUS PstAcquirePrivateKey(CERT_CONTEXT* pCert) #uselib "certpoleng.dll" #cfunc global PstAcquirePrivateKey "PstAcquirePrivateKey" var ; res = PstAcquirePrivateKey(pCert) ; pCert : CERT_CONTEXT* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; NTSTATUS PstAcquirePrivateKey(CERT_CONTEXT* pCert) #uselib "certpoleng.dll" #cfunc global PstAcquirePrivateKey "PstAcquirePrivateKey" intptr ; res = PstAcquirePrivateKey(varptr(pCert)) ; pCert : CERT_CONTEXT* -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
certpoleng = windows.NewLazySystemDLL("certpoleng.dll")
procPstAcquirePrivateKey = certpoleng.NewProc("PstAcquirePrivateKey")
)
// pCert (CERT_CONTEXT*)
r1, _, err := procPstAcquirePrivateKey.Call(
uintptr(pCert),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // NTSTATUSfunction PstAcquirePrivateKey(
pCert: Pointer // CERT_CONTEXT*
): Integer; stdcall;
external 'certpoleng.dll' name 'PstAcquirePrivateKey';result := DllCall("certpoleng\PstAcquirePrivateKey"
, "Ptr", pCert ; CERT_CONTEXT*
, "Int") ; return: NTSTATUS●PstAcquirePrivateKey(pCert) = DLL("certpoleng.dll", "int PstAcquirePrivateKey(void*)")
# 呼び出し: PstAcquirePrivateKey(pCert)
# pCert : CERT_CONTEXT* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。