Support for registering the new functionality in a system registry must be provided in the new DLL along with the new function. CryptoAPI functions are provided for assisting with this registration. (See OID Support Functions for details). The methodology used for registering the new functions is the use of Regsvr32.exe. This utility is provided with both Microsoft Windows NT® and Microsoft Windows® 95.
The new DLL must provide DllRegisterServer and DllUnregisterServer entry points for use by Regsvr32.exe. The CryptoAPI functions can be used within these entry points, as shown in the example code fragments that follow:
STDAPI DllRegisterServer(void)
{
if(!CryptRegisterOIDFunction(
X509_ASN_ENCODING, // Encoding type
CRYPT_OID_ENCODE_OBJECT_FUNC, // Function name
szOID_NEW_CERTIFICATE_TYPE, // OID
L"NewCert.dll", // Dll name
L"NewCertificateTypeEncodeObject")) // Override function
// name
return E_FAIL;
return S_OK;
}
STDAPI DllUnregisterServer(void)
{
HRESULT hr = S_OK;
if(!CryptUnregisterOIDFunction(
X509_ASN_ENCODING, // Encoding type
CRYPT_OID_ENCODE_OBJECT_FUNC, // Function name
szOID_NEW_CERTIFICATE_TYPE)) // OID
{
if(ERROR_FILE_NOT_FOUND != GetLastError())
hr = E_FAIL;
}
return hr;
}
This code must be compiled and linked into the new DLL, and these entry points, along with the function entry points, must be exported.
Users that need to install the new functionality on their computers, must run Regsvr32.exe from a command prompt window, specifying the name and path of the new DLL. Regsvr32.exe accesses CryptRegisterOIDFunction via the DllRegisterServer entry point, causing the new function and DLL to get registered in the registry.