Historical Content Alert
This is a historical content for Windows NT 4.0 product and is presented for informative purposes only. All content in this directory is copyrighted and owned by Microsoft.

Method Return Values

For each interface method there are three prototypes shown, each of which has the [VB], [JAVA], or [C++] notation beside it. In most cases the method prototypes return different values, depending on which language is being used.

Return Values For Microsoft Visual Basic

The return value is usually handled by a variant data structure that will automatically handle whatever type is returned. A method call would be as follows:

Dim AttributeValue As VARIANT  'return value

AttributeValue = GetRequestAttribute("TheAttribute")
 

In this example code fragment, the return variable AttributeValue would be accepting a VT_BSTR type.

Return Values For Java

The return type will be of one of the java.lang.XXX class types; such as java.lang.String, or com.ms.Variant. A method call would be as follows:

com.ms.Variant    AttributeValue;  // return value

AttributeValue = GetRequestAttribute("TheAttribute");
 

In this example code fragment, the variable AttributeValue would be accepting a com.ms.Variant type.

Return Values For Microsoft C++

The return value is always of type HRESULT, and it is from this return value that it can be determined whether the method succeeded or not, and if not, what the error was. Programmatic values that need to be returned are returned through "output" parameters in the method. The following example shows a C++ method call to retrieve a request attribute:

HRESULT hr;
BSTR strAttributeName = SysAllocString("TheAttribute");
BSTR strAttributeValue = SysAllocStringByteLen("", 49);

hr = pICertServerPolicy->GetRequestAttribute(
                                strAttributeName,
                                &strAttributeValue);
HRESULT hr;
BSTR strAttributeName = SysAllocString("TheAttribute");
BSTR strAttributeValue = NULL;

hr = pICertServerPolicy->GetRequestAttribute(
                                strAttributeName,
                                &strAttributeValue);

// Use strAttributeValue ... 

// then free it when done
if (NULL != strAttributeName)
{
    SysFreeString(strAttributeName);
}
if (NULL != strAttributeValue)
{
    SysFreeString(strAttributeValue);
}

In the preceding code fragment, success or failure is returned to the "hr" variable. The request attribute value is a string returned in the BSTR strAttributeValue parameter.


Share this article: