EDN Admin
Well-known member
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:oPreview()
{
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
Looking for a good COM programming tutorial.
thanks,
<pre class="prettyprint HRESULT CRecipePreviewHandler:oPreview()
{
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