Sample code for 30+ languages & platforms
Xbase++ Requires Chilkat v10.1.2+

List Certificates in the Current User Certificate Store (Windows Only)

See more Certificates Examples

This is a Windows-only example to list the certificates in the current-user certificate store (located in the Windows Registry).

Chilkat Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oCertStore
LOCAL nReadOnly
LOCAL oCert
LOCAL nNumCerts
LOCAL i

nSuccess := 0

//  This is a Windows-only example because it lists the certificates
//  stored in the Windows Current User Certificate Store located in the
//  Windows Registry.

oCertStore := CreateObject("Chilkat.CertStore")

nReadOnly := 1
nSuccess := oCertStore:OpenCurrentUserStore(nReadOnly)
IF (nSuccess == 0)
    ? oCertStore:LastErrorText
    oCertStore:destroy()
    RETURN
ENDIF

oCert := CreateObject("Chilkat.Cert")
nNumCerts := oCertStore:NumCertificates
i := 0
DO WHILE i < nNumCerts
    oCertStore:GetCert(i, oCert)
    ? "DN = " + oCert:SubjectDN
    ? "Email = " + oCert:SubjectE
    i := i + 1
ENDDO

oCertStore:destroy()
oCert:destroy()