CertificateStoreUnregisterSystemStore Method
Unregisters an existing system certificate store.

Namespace: MailBee.Security
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.4 build 677 for .NET 4.5
Syntax
public static void UnregisterSystemStore(
	string name,
	RegistryStoreLocation registryLocation
)

Parameters

name
Type: SystemString
The name of the existing system store.
registryLocation
Type: MailBee.SecurityRegistryStoreLocation
The store location in the registry.
Exceptions
ExceptionCondition
MailBeeInvalidArgumentExceptionname is a null reference (Nothing in Visual Basic).
MailBeeCertificateStoreWin32ExceptionWin32 returned an error on attempt to register a store.
Remarks
Unregistering the store physically removes the store along with all the certificates.
Note Note
It's not recommended to unregister system stores unless they had been created by your applications. Unregistering a store which is used by the operating system may cause unpredictable results.
Note Note
This method is not available in .NET Standard 2.0 edition and newer (because it relies on Win32 API).
Examples
This sample registers a store, fills it with some certificates (copied from another store), and unregisters it.
// To use the code below, import MailBee namespace at the top of your code
using MailBee.Security;

// The actual code (put it into a method of your class).
CertificateStore.RegisterSystemStore("TestStore", RegistryStoreLocation.CurrentUser);
CertificateStore newStore = new CertificateStore("TestStore", CertStoreType.System, null);
CertificateStore myStore = new CertificateStore(CertificateStore.Personal, CertStoreType.System, null);
CertificateCollection coll = myStore.FindCertificates("thawte", CertificateFields.EmailAddress);

newStore.AddCertificates(coll, false);
coll = newStore.GetAllCertificates();

foreach (Certificate cert in coll)
{
    Console.WriteLine(cert.IssuedTo);
    Console.WriteLine(cert.IssuedBy);
    Console.WriteLine(cert.EmailAddress);
    Console.WriteLine(cert.ValidToDate);
    Console.WriteLine("Has private key: " + cert.HasPrivateKey);
    Console.WriteLine("------------------------------");
}
CertificateStore.UnregisterSystemStore("TestStore", RegistryStoreLocation.CurrentUser);
See Also