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