Sample code for 30+ languages & platforms
PowerBuilder

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 PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_CertStore
integer li_ReadOnly
oleobject loo_Cert
integer li_NumCerts
integer i

li_Success = 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.

loo_CertStore = create oleobject
li_rc = loo_CertStore.ConnectToNewObject("Chilkat.CertStore")
if li_rc < 0 then
    destroy loo_CertStore
    MessageBox("Error","Connecting to COM object failed")
    return
end if

li_ReadOnly = 1
li_Success = loo_CertStore.OpenCurrentUserStore(li_ReadOnly)
if li_Success = 0 then
    Write-Debug loo_CertStore.LastErrorText
    destroy loo_CertStore
    return
end if

loo_Cert = create oleobject
li_rc = loo_Cert.ConnectToNewObject("Chilkat.Cert")

li_NumCerts = loo_CertStore.NumCertificates
i = 0
do while i < li_NumCerts
    loo_CertStore.GetCert(i,loo_Cert)
    Write-Debug "DN = " + loo_Cert.SubjectDN
    Write-Debug "Email = " + loo_Cert.SubjectE
    i = i + 1
loop


destroy loo_CertStore
destroy loo_Cert