[This is preliminary documentation and subject to change.]
The OpenConnection method establishes a connection with a Certificate Server.
[VB] OpenConnection(
String strConfig
);
[JAVA] OpenConnection(
java.lang.String strConfig
);
[C++] HRESULT OpenConnection(
BSTR const strConfig // in
);
[C++]The return value is an HRESULT. A value of S_OK indicates success.
Upon successful completion of this function, the ICertView object will have a connection to the Certificate Server referenced by strConfig.
[C++] To close the connection, call ICertView::Release.
ICertView * pCertView = NULL;
BSTR strCertServ = NULL;
HRESULT hr;
// initialize COM
hr = CoInitializeEx( NULL, COINIT_APARTMENTTHREADED );
if ( FAILED( hr ) )
{
printf("Failed CoInitializeEx\n");
goto error;
}
// get pointer to the ICertView interface
hr = CoCreateInstance( CLSID_CCertView,
NULL,
CLSCTX_INPROC_SERVER,
IID_ICertView,
(void **)&pCertView);
if ( FAILED( hr ) )
{
printf("Failed CoCreateInstance\n");
goto error;
}
// the use of '\\' is necessary to represent a single backslash
strCertServ = SysAllocString(TEXT("Server01\\ABCCertServ"));
// open the connection to the certificate server
hr = pCertView->OpenConnection( strCertServ );
if ( FAILED( hr ) )
{
printf("Failed OpenConnection!\n");
goto error;
}else
// established successful connection; use view as appropriate
…
// done using objects; free resources
error:
if ( NULL != pCertView )
pCertView->Release();
if ( NULL != strCertServ )
SysFreeString( strCertServ );
// free COM resources
CoUninitialize();
Windows NT: Requires version 5.0 or later.
Windows: Unsupported.
Windows CE: Unsupported.
Header: Declared in certview.h.
Import Library: Use certidl.lib.