本文整理汇总了C++中CComBSTR::ReadFromStream方法的典型用法代码示例。如果您正苦于以下问题:C++ CComBSTR::ReadFromStream方法的具体用法?C++ CComBSTR::ReadFromStream怎么用?C++ CComBSTR::ReadFromStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CComBSTR
的用法示例。
在下文中一共展示了CComBSTR::ReadFromStream方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: send
STDMETHODIMP CXMLHttpRequest::send(VARIANT varBody)
{
ATLTRACE(_T("CXMLHttpRequest::send\n"));
if (V_VT(&varBody) != VT_BSTR &&
V_VT(&varBody) != VT_DISPATCH &&
V_VT(&varBody) != (VT_ARRAY | VT_VARIANT) &&
V_VT(&varBody) != (VT_ARRAY | VT_UI1) &&
V_VT(&varBody) != VT_UNKNOWN)
return E_INVALIDARG;
// do not start another thread if there is another active
if (NULL != m_hThread) {
DWORD exitCode = 0;
BOOL rc = ::GetExitCodeThread(m_hThread, &exitCode);
if (!rc || STILL_ACTIVE == exitCode)
return E_PENDING;
::CloseHandle(m_hThread);
m_hThread = NULL;
}
HRESULT hr = S_OK;
m_bSuccess = true;
m_bAbort = false;
delete [] m_pBody;
m_pBody = NULL;
m_lBodyLength = 0;
delete [] m_pResponseBody;
m_pResponseBody = NULL;
m_lResponseBodyLength = 0;
m_dwStatus = 0;
m_StatusText = _T("");
m_ResponseHeaders = _T("");
if (V_VT(&varBody) == VT_BSTR) {
_bstr_t body = V_BSTR(&varBody);
m_lBodyLength = body.length() + 1;
m_pBody = new BYTE[m_lBodyLength];
memset(m_pBody,0,m_lBodyLength);
memcpy(m_pBody,static_cast<char*> (body),body.length());
}
else if (V_VT(&varBody) == VT_UNKNOWN) {
CComQIPtr<IStream,&IID_IStream> pS(V_UNKNOWN(&varBody));
if (!pS)
return E_INVALIDARG;
CComBSTR b;
hr = b.ReadFromStream(pS);
if (S_OK != hr)
return hr;
_bstr_t body = b;
m_lBodyLength = body.length() + 1;
m_pBody = new BYTE[m_lBodyLength];
memset(m_pBody,0,m_lBodyLength);
memcpy(m_pBody,static_cast<char*> (body),body.length());
}
else if (V_VT(&varBody) == VT_DISPATCH) {
CComQIPtr<IXMLDOMDocument,&IID_IXMLDOMDocument> pDoc(V_DISPATCH(&varBody));
if (!pDoc)
return E_INVALIDARG;
BSTR b = NULL;
hr = pDoc->get_xml(&b);
if (S_OK != hr)
return hr;
_bstr_t body = b;
::SysFreeString(b);
m_lBodyLength = body.length() + 1;
m_pBody = new BYTE[m_lBodyLength];
memset(m_pBody,0,m_lBodyLength);
memcpy(m_pBody,static_cast<char*> (body),body.length());
}
else if (V_VT(&varBody) == (VT_ARRAY | VT_VARIANT)) {
SAFEARRAY *pArray = reinterpret_cast<SAFEARRAY *> (varBody.byref);
if (NULL == pArray)
return E_INVALIDARG;
long lLBoundVar = 0;
long lUBoundVar = 0;
UINT dims = ::SafeArrayGetDim(pArray);
if (dims == 0)
return E_INVALIDARG;
hr = ::SafeArrayGetLBound(pArray, dims, &lLBoundVar);
if (S_OK != hr)
return hr;
hr = ::SafeArrayGetUBound(pArray, dims, &lUBoundVar);
if (S_OK != hr)
return hr;
if (lUBoundVar >= lLBoundVar) {
VARIANT *pIndex = NULL;
hr = ::SafeArrayAccessData(pArray, reinterpret_cast<void **> (&pIndex));
if (S_OK != hr)
//.........这里部分代码省略.........