Platform SDK: Certificate Enrollment Control |
For each interface method there are two prototypes shown, each of which has the [Visual Basic] or [C++] notation beside it. The method prototypes return different values depending on which language is used.
The return value is always of type HRESULT; this value can be checked to determine success or failure. The use of "output" parameters allows values to be assigned to variables during the method or property call. The following example shows a C++ method call to enumerate providers:
UINT ucEnumProvIndex = 0; BSTR bstrProvider = NULL; HRESULT hr; // pEnroll is previously instantiated CEnroll interface pointer hr = pEnroll->enumProviders(ucEnumProvIndex, 0, &bstrProvider);
In the preceding code fragment, success or failure is returned to the "hr" variable. If the call was successful, hr will be set to S_OK and the variable bstrProvider will contain the name of the enumerated provider.
A C++ call to retrieve a property value would be as follows:
BSTR bstrStoreName = NULL; HRESULT hr; // pEnroll is previously instantiated CEnroll interface pointer // get the storename hr = pEnroll->get_CAStoreName( &bstrStoreName ); // (When done using bstrStoreName, free it by calling SysFreeString).
A C++ call to set a property value would be as follows:
// bstrNewName previously set to a valid store name hr = pEnroll->put_CAStoreName( bstrNewName );
The return value is of the type specified by the particular method or property. A call to retrieve a property value would be as follows:
' objXen is previously instantiated Certificate Enrollment object. Dim strCAStoreName As String ' Retrieve the CAStoreName. strCAStoreName = objXen.CAStoreName
A call to a method would be as follows:
' objXen is previously instantiated Certificate Enrollment object. ' strDN and strUsage are previously defined String variables. Dim strPKCS10 As String ' Create the PKCS #10 request. strPKCS10 = objXen.createPKCS10( strDN, strUsage )
An alternative to assigning method and property return values to a specific type is to assign them to Variant variables. For example:
Dim myPKCS10 As Variant ' Create the PKCS10 request. myPKCS10 = objXen.createPKCS10( strDN, strUsage )