proper way of handling [out,retval] VARIANT * args



Oh wise masters of COM:

what's the proper way to handle an [out,retval] VARIANT *arg ?
Do you use VariantInit() after checking for a null arg, or
VariantClear?

STDMETHODIMP CBlah::get_something(VARIANT *pVal)
{
if (pVal == NULL)
return E_POINTER;

VariantInit(pVal);

// do some stuff, it may return an error

// everything is great, assign the VARIANT
CComBSTR b = L"something from blah";
V_VT(pVal) = VT_BSTR;
V_BSTR(pVal) = b.Detach();
return S_OK;
}

.



Relevant Pages

  • Re: Help with function created in VBA
    ... Function MinPrice5As Variant) As Variant 'text or ... Dim arg As Variant ... Dim FoundANumber As Boolean ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Help with function created in VBA
    ... Function MinPrice5As Variant) As Variant 'text or ... Dim arg As Variant ... Dim FoundANumber As Boolean ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Create Function using Excel VBA
    ... Function MinPriceAs Variant) As Variant 'text or number ... Dim arg As Variant ... Dim FoundANumber As Boolean ... Dim myMin As Double ...
    (microsoft.public.excel.programming)
  • Re: Create Function using Excel VBA
    ... For Each arg In arglist ... Function MinPriceAs Variant) As Variant 'text or number ... Dim FoundANumber As Boolean ... value of the arguments that pass the validation process. ...
    (microsoft.public.excel.programming)
  • Re: Cantors definition of set
    ... thinking of a variant of ZFC with urelements here; no proper classes.) ...
    (sci.logic)