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

CertEnumSystemStoreLocation

関数
システム証明書ストアの場所をコールバックで列挙する。
DLLCRYPT32.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

BOOL CertEnumSystemStoreLocation(
    DWORD dwFlags,
    void* pvArg,   // optional
    PFN_CERT_ENUM_SYSTEM_STORE_LOCATION pfnEnum
);

パラメーター

名前方向
dwFlagsDWORDin
pvArgvoid*inoutoptional
pfnEnumPFN_CERT_ENUM_SYSTEM_STORE_LOCATIONin

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL CertEnumSystemStoreLocation(
    DWORD dwFlags,
    void* pvArg,   // optional
    PFN_CERT_ENUM_SYSTEM_STORE_LOCATION pfnEnum
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("CRYPT32.dll", ExactSpelling = true)]
static extern bool CertEnumSystemStoreLocation(
    uint dwFlags,   // DWORD
    IntPtr pvArg,   // void* optional, in/out
    IntPtr pfnEnum   // PFN_CERT_ENUM_SYSTEM_STORE_LOCATION
);
<DllImport("CRYPT32.dll", ExactSpelling:=True)>
Public Shared Function CertEnumSystemStoreLocation(
    dwFlags As UInteger,   ' DWORD
    pvArg As IntPtr,   ' void* optional, in/out
    pfnEnum As IntPtr   ' PFN_CERT_ENUM_SYSTEM_STORE_LOCATION
) As Boolean
End Function
' dwFlags : DWORD
' pvArg : void* optional, in/out
' pfnEnum : PFN_CERT_ENUM_SYSTEM_STORE_LOCATION
Declare PtrSafe Function CertEnumSystemStoreLocation Lib "crypt32" ( _
    ByVal dwFlags As Long, _
    ByVal pvArg As LongPtr, _
    ByVal pfnEnum As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CertEnumSystemStoreLocation = ctypes.windll.crypt32.CertEnumSystemStoreLocation
CertEnumSystemStoreLocation.restype = wintypes.BOOL
CertEnumSystemStoreLocation.argtypes = [
    wintypes.DWORD,  # dwFlags : DWORD
    ctypes.POINTER(None),  # pvArg : void* optional, in/out
    ctypes.c_void_p,  # pfnEnum : PFN_CERT_ENUM_SYSTEM_STORE_LOCATION
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('CRYPT32.dll')
CertEnumSystemStoreLocation = Fiddle::Function.new(
  lib['CertEnumSystemStoreLocation'],
  [
    -Fiddle::TYPE_INT,  # dwFlags : DWORD
    Fiddle::TYPE_VOIDP,  # pvArg : void* optional, in/out
    Fiddle::TYPE_VOIDP,  # pfnEnum : PFN_CERT_ENUM_SYSTEM_STORE_LOCATION
  ],
  Fiddle::TYPE_INT)
#[link(name = "crypt32")]
extern "system" {
    fn CertEnumSystemStoreLocation(
        dwFlags: u32,  // DWORD
        pvArg: *mut (),  // void* optional, in/out
        pfnEnum: *const core::ffi::c_void  // PFN_CERT_ENUM_SYSTEM_STORE_LOCATION
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("CRYPT32.dll")]
public static extern bool CertEnumSystemStoreLocation(uint dwFlags, IntPtr pvArg, IntPtr pfnEnum);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CRYPT32_CertEnumSystemStoreLocation' -Namespace Win32 -PassThru
# $api::CertEnumSystemStoreLocation(dwFlags, pvArg, pfnEnum)
#uselib "CRYPT32.dll"
#func global CertEnumSystemStoreLocation "CertEnumSystemStoreLocation" sptr, sptr, sptr
; CertEnumSystemStoreLocation dwFlags, pvArg, pfnEnum   ; 戻り値は stat
; dwFlags : DWORD -> "sptr"
; pvArg : void* optional, in/out -> "sptr"
; pfnEnum : PFN_CERT_ENUM_SYSTEM_STORE_LOCATION -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "CRYPT32.dll"
#cfunc global CertEnumSystemStoreLocation "CertEnumSystemStoreLocation" int, sptr, sptr
; res = CertEnumSystemStoreLocation(dwFlags, pvArg, pfnEnum)
; dwFlags : DWORD -> "int"
; pvArg : void* optional, in/out -> "sptr"
; pfnEnum : PFN_CERT_ENUM_SYSTEM_STORE_LOCATION -> "sptr"
; BOOL CertEnumSystemStoreLocation(DWORD dwFlags, void* pvArg, PFN_CERT_ENUM_SYSTEM_STORE_LOCATION pfnEnum)
#uselib "CRYPT32.dll"
#cfunc global CertEnumSystemStoreLocation "CertEnumSystemStoreLocation" int, intptr, intptr
; res = CertEnumSystemStoreLocation(dwFlags, pvArg, pfnEnum)
; dwFlags : DWORD -> "int"
; pvArg : void* optional, in/out -> "intptr"
; pfnEnum : PFN_CERT_ENUM_SYSTEM_STORE_LOCATION -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	crypt32 = windows.NewLazySystemDLL("CRYPT32.dll")
	procCertEnumSystemStoreLocation = crypt32.NewProc("CertEnumSystemStoreLocation")
)

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