Visual Basic Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

VB Examples

Bounced Mail
Character Encoding
Digital Certificates
Digital Signatures
Email
FTP
HTML-to-XML
HTTP
IMAP
Encryption
MHT / HTML Email
RSA Encryption
S/MIME
Socket
Spider
String
Tar
Unicode
Upload
XML
XMP
Zip Compression

More Examples...
Email Object
POP3
SMTP
RSS
Atom
Self-Extractor


VB Strings
VB Byte Array

Unreleased...
Service
PPMD
Deflate
Bzip2
LZW
Bz2
DH Key Exchange
DSA
Icon

 

 

 

 

 

 

 

Create a New Certificate Store in the Windows Registry

This Visual Basic example program creates a new certificate store located in the Windows registry, and copies certificates from the Outlook certificate store into the new cert store.

' Visual Basic program to create a new certificate store
' located in the Windows registry.
' This program opens an existing certificate store and
' copies the certificates from it into the new
' cert store.
Private Sub Command1_Click()

    ' Create the Cert Store Creator
    Dim csCreator As ChilkatCreateCS
    Set csCreator = New ChilkatCreateCS
    csCreator.ReadOnly = 0
    
    ' Create a new certificate store in the registry.
    Dim cs0 As ChilkatCertStore
    
    ' The first param can be "CurrentUser" or "LocalMachine"
    If (OptLocalMachine.Value = True) Then
        Set cs0 = csCreator.CreateRegistryStore("LocalMachine", Text2.Text)
    Else
        Set cs0 = csCreator.CreateRegistryStore("CurrentUser", Text2.Text)
    End If
    
    ' Open an existing store.
    Dim cs1 As ChilkatCertStore
    Set cs1 = csCreator.OpenOutlookStore()
    
    Text1.Text = Text1.Text & "Adding certs from Outlook store..." & vbCrLf

    Dim cert As ChilkatCert
    For i = 0 To cs1.NumCertificates - 1
        Set cert = cs1.GetCertificate(i)
        cs0.AddCertificate cert
        Text1.Text = Text1.Text & "CN=" & cert.SubjectCN & ",E=" & cert.SubjectE & ",O=" & cert.SubjectO & vbCrLf
    Next
    Text1.Text = Text1.Text & "-------------------------" & vbCrLf
    Label1.Caption = "Status: " & Str(cs1.NumCertificates) & " loaded into new cert store"
    
    Set cs0 = Nothing
    Set cs1 = Nothing

    ' Now open the file store and read the certs.
    Text1.Text = Text1.Text & "Opening the certificate store just created..." & vbCrLf
    
    If (OptLocalMachine.Value = True) Then
        Set cs0 = csCreator.OpenRegistryStore("LocalMachine", Text2.Text, True)
    Else
        Set cs0 = csCreator.OpenRegistryStore("CurrentUser", Text2.Text, True)
    End If
    
    Text1.Text = Text1.Text & "Number of certificates = " & cs0.NumCertificates & vbCrLf
    For i = 0 To cs0.NumCertificates - 1
        Set cert = cs0.GetCertificate(i)
        Text1.Text = Text1.Text & "CN=" & cert.SubjectCN & ",E=" & cert.SubjectE & ",O=" & cert.SubjectO & vbCrLf
    Next

    csCreator.SaveXmlLog "log.xml"
    
End Sub

 

Need a specific example? Send a request to support@chilkatsoft.com

© 2000-2008 Chilkat Software, Inc. All Rights Reserved.