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

CertAddStoreToCollection

関数
コレクションストアに兄弟ストアを追加する。
DLLCRYPT32.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

BOOL CertAddStoreToCollection(
    HCERTSTORE hCollectionStore,
    HCERTSTORE hSiblingStore,   // optional
    DWORD dwUpdateFlags,
    DWORD dwPriority
);

パラメーター

名前方向
hCollectionStoreHCERTSTOREin
hSiblingStoreHCERTSTOREinoptional
dwUpdateFlagsDWORDin
dwPriorityDWORDin

戻り値の型: BOOL

各言語での呼び出し定義

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

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

CertAddStoreToCollection = ctypes.windll.crypt32.CertAddStoreToCollection
CertAddStoreToCollection.restype = wintypes.BOOL
CertAddStoreToCollection.argtypes = [
    wintypes.HANDLE,  # hCollectionStore : HCERTSTORE
    wintypes.HANDLE,  # hSiblingStore : HCERTSTORE optional
    wintypes.DWORD,  # dwUpdateFlags : DWORD
    wintypes.DWORD,  # dwPriority : DWORD
]
require 'fiddle'
require 'fiddle/import'

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

var (
	crypt32 = windows.NewLazySystemDLL("CRYPT32.dll")
	procCertAddStoreToCollection = crypt32.NewProc("CertAddStoreToCollection")
)

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