Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
Create a New Certificate Store in the Windows RegistryThis 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
|
© 2000-2012 Chilkat Software, Inc. All Rights Reserved.