CertificateStore Object : DeleteCert Method |
Visual Basic |
---|
Public Sub DeleteCert( _ ByVal Cert As Certificate _ ) |
This method is used to remove an existing certificate from a certificate store. If the certificate does not exist a certNotFound error will be thrown. If the certificate cant be deleted a certNoDelete error will be thrown. For any other error a certError will be thrown.
This method may generate the following error code (refer to ErrorConstants for a complete list of error codes):
Private Sub DeleteSelectedCert() On Error GoTo OnError Dim Item As ListItem Set Item = lvwCerts.SelectedItem If Item Is Nothing Then Exit Sub Dim Cert As Certificate Set Cert = Item.Tag If MsgBox("Are you sure you want to delete " + Cert.IssuedTo + "?", vbQuestion + vbOKCancel, "Confirm Delete") <> vbOK Then Exit Sub Dim Store As CertificateStore Set Store = New CertificateStore Store.Name = m_StoreName Store.Location = m_StoreLocation Store.DeleteCert Cert RefreshCerts GoTo Done OnError: MsgBox Err.Description, vbCritical, "ERROR #" + CStr(Err.Number) Done: End Sub