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*inoutoptionalvoid へのポインターです。これにより、アプリケーションはコールバック列挙関数に渡す情報を保持する構造体を宣言、定義、および初期化できます。
pfnEnumPFN_CERT_ENUM_SYSTEM_STORE_LOCATIONin各ストアの場所の詳細を表示するために使用されるコールバック関数へのポインターです。このコールバック関数は、各ストアの場所に関する情報を提示する際の内容と形式を決定します。コールバック関数のシグネチャとパラメーターについては、CertEnumSystemStoreLocationCallback を参照してください。

戻り値の型: BOOL

公式ドキュメント

CertEnumSystemStoreLocation 関数は、すべてのシステムストアの場所を取得します。この関数は、見つかったシステムストアの場所ごとに、指定されたコールバック関数を呼び出します。

戻り値

関数が成功した場合は、TRUE を返します。

関数が失敗した場合は、FALSE を返します。

解説(Remarks)

CertEnumSystemStoreLocation を使用するには、アプリケーションは ENUM_ARG 構造体と列挙コールバック関数を宣言および定義する必要があります。

Examples

この関数を使用する例については、 Example C Program: Listing System and Physical Stores を参照してください。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

// 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 <MarshalAs(UnmanagedType.Bool)> 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)。
const std = @import("std");

extern "crypt32" fn CertEnumSystemStoreLocation(
    dwFlags: u32, // DWORD
    pvArg: ?*anyopaque, // void* optional, in/out
    pfnEnum: ?*anyopaque // PFN_CERT_ENUM_SYSTEM_STORE_LOCATION
) callconv(std.os.windows.WINAPI) i32;
proc CertEnumSystemStoreLocation(
    dwFlags: uint32,  # DWORD
    pvArg: pointer,  # void* optional, in/out
    pfnEnum: pointer  # PFN_CERT_ENUM_SYSTEM_STORE_LOCATION
): int32 {.importc: "CertEnumSystemStoreLocation", stdcall, dynlib: "CRYPT32.dll".}
pragma(lib, "crypt32");
extern(Windows)
int CertEnumSystemStoreLocation(
    uint dwFlags,   // DWORD
    void* pvArg,   // void* optional, in/out
    void* pfnEnum   // PFN_CERT_ENUM_SYSTEM_STORE_LOCATION
);
ccall((:CertEnumSystemStoreLocation, "CRYPT32.dll"), stdcall, Int32,
      (UInt32, Ptr{Cvoid}, Ptr{Cvoid}),
      dwFlags, pvArg, pfnEnum)
# dwFlags : DWORD -> UInt32
# pvArg : void* optional, in/out -> Ptr{Cvoid}
# pfnEnum : PFN_CERT_ENUM_SYSTEM_STORE_LOCATION -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t CertEnumSystemStoreLocation(
    uint32_t dwFlags,
    void* pvArg,
    void* pfnEnum);
]]
local crypt32 = ffi.load("crypt32")
-- crypt32.CertEnumSystemStoreLocation(dwFlags, pvArg, pfnEnum)
-- dwFlags : DWORD
-- pvArg : void* optional, in/out
-- pfnEnum : PFN_CERT_ENUM_SYSTEM_STORE_LOCATION
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('CRYPT32.dll');
const CertEnumSystemStoreLocation = lib.func('__stdcall', 'CertEnumSystemStoreLocation', 'int32_t', ['uint32_t', 'void *', 'void *']);
// CertEnumSystemStoreLocation(dwFlags, pvArg, pfnEnum)
// dwFlags : DWORD -> 'uint32_t'
// pvArg : void* optional, in/out -> 'void *'
// pfnEnum : PFN_CERT_ENUM_SYSTEM_STORE_LOCATION -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
// コールバック(関数ポインタ)は koffi.proto/koffi.register で型を定義して渡す(素の void* では JS 関数を渡せない)。
const lib = Deno.dlopen("CRYPT32.dll", {
  CertEnumSystemStoreLocation: { parameters: ["u32", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.CertEnumSystemStoreLocation(dwFlags, pvArg, pfnEnum)
// dwFlags : DWORD -> "u32"
// pvArg : void* optional, in/out -> "pointer"
// pfnEnum : PFN_CERT_ENUM_SYSTEM_STORE_LOCATION -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t CertEnumSystemStoreLocation(
    uint32_t dwFlags,
    void* pvArg,
    void* pfnEnum);
C, "CRYPT32.dll");
// $ffi->CertEnumSystemStoreLocation(dwFlags, pvArg, pfnEnum);
// dwFlags : DWORD
// pvArg : void* optional, in/out
// pfnEnum : PFN_CERT_ENUM_SYSTEM_STORE_LOCATION
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface Crypt32 extends StdCallLibrary {
    Crypt32 INSTANCE = Native.load("crypt32", Crypt32.class);
    boolean CertEnumSystemStoreLocation(
        int dwFlags,   // DWORD
        Pointer pvArg,   // void* optional, in/out
        Callback pfnEnum   // PFN_CERT_ENUM_SYSTEM_STORE_LOCATION
    );
}
@[Link("crypt32")]
lib LibCRYPT32
  fun CertEnumSystemStoreLocation = CertEnumSystemStoreLocation(
    dwFlags : UInt32,   # DWORD
    pvArg : Void*,   # void* optional, in/out
    pfnEnum : Void*   # PFN_CERT_ENUM_SYSTEM_STORE_LOCATION
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef CertEnumSystemStoreLocationNative = Int32 Function(Uint32, Pointer<Void>, Pointer<Void>);
typedef CertEnumSystemStoreLocationDart = int Function(int, Pointer<Void>, Pointer<Void>);
final CertEnumSystemStoreLocation = DynamicLibrary.open('CRYPT32.dll')
    .lookupFunction<CertEnumSystemStoreLocationNative, CertEnumSystemStoreLocationDart>('CertEnumSystemStoreLocation');
// dwFlags : DWORD -> Uint32
// pvArg : void* optional, in/out -> Pointer<Void>
// pfnEnum : PFN_CERT_ENUM_SYSTEM_STORE_LOCATION -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
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';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "CertEnumSystemStoreLocation"
  c_CertEnumSystemStoreLocation :: Word32 -> Ptr () -> Ptr () -> IO CInt
-- dwFlags : DWORD -> Word32
-- pvArg : void* optional, in/out -> Ptr ()
-- pfnEnum : PFN_CERT_ENUM_SYSTEM_STORE_LOCATION -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let certenumsystemstorelocation =
  foreign "CertEnumSystemStoreLocation"
    (uint32_t @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* dwFlags : DWORD -> uint32_t *)
(* pvArg : void* optional, in/out -> (ptr void) *)
(* pfnEnum : PFN_CERT_ENUM_SYSTEM_STORE_LOCATION -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library crypt32 (t "CRYPT32.dll"))
(cffi:use-foreign-library crypt32)

(cffi:defcfun ("CertEnumSystemStoreLocation" cert-enum-system-store-location :convention :stdcall) :int32
  (dw-flags :uint32)   ; DWORD
  (pv-arg :pointer)   ; void* optional, in/out
  (pfn-enum :pointer))   ; PFN_CERT_ENUM_SYSTEM_STORE_LOCATION
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $CertEnumSystemStoreLocation = Win32::API::More->new('CRYPT32',
    'BOOL CertEnumSystemStoreLocation(DWORD dwFlags, LPVOID pvArg, LPVOID pfnEnum)');
# my $ret = $CertEnumSystemStoreLocation->Call($dwFlags, $pvArg, $pfnEnum);
# dwFlags : DWORD -> DWORD
# pvArg : void* optional, in/out -> LPVOID
# pfnEnum : PFN_CERT_ENUM_SYSTEM_STORE_LOCATION -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# コールバック(関数ポインタ)は Perl sub を直接渡せません。Win32::API::Callback を使用してください。

関連項目

公式の関連項目
使用する型