what do the V_VT and V_UNKNOWN macros do?

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
what does the V_VT and V_UNKNOWN macros do in the following code sample?
Looking for a good COM programming tutorial.
thanks,
<pre class="prettyprint HRESULT CRecipePreviewHandler::DoPreview()
{
HRESULT hr = E_FAIL;

// cannot call more than once (Unload should be called before another DoPreview)
if (_hwndPreview == NULL && _pStream)
{
IXMLDOMDocument *pDomDoc;

// We will use the DOM interface from MSXML to load up our file (which is xml format)
// and convert it to rich text format using an xml style-sheet
hr = CoCreateInstance(
__uuidof(DOMDocument60), NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pDomDoc));
if (SUCCEEDED(hr))
{
VARIANT_BOOL vfSuccess = VARIANT_FALSE;
VARIANT vtXmlSource = {0};
V_VT(&vtXmlSource) = VT_UNKNOWN;
V_UNKNOWN(&vtXmlSource) = static_cast<IUnknown *>(_pStream);
hr = pDomDoc->load(vtXmlSource, &vfSuccess);

if (vfSuccess != VARIANT_TRUE)
{
hr = FAILED(hr) ? hr : E_FAIL; // keep failed hr
}

if (SUCCEEDED(hr))
{
if (_pStyleSheetNode == NULL)
{
hr = _CreateStyleSheetNode();
}

if (SUCCEEDED(hr))
{
BSTR bstrRtf;
hr = pDomDoc->transformNode(_pStyleSheetNode, &bstrRtf);
if (SUCCEEDED(hr))
{
hr = _CreatePreviewWindow(bstrRtf);
SysFreeString(bstrRtf);
}
}
}
pDomDoc->Release();
}
}
return hr;
}
[/code]
<br/>

View the full article
 
Back
Top