Ejemplo n.º 1
0
	virtual void ProcessAttach(void)
	{
		HRESULT hr;

		if (FAILED(hr = ::CreateErrorInfo(&s_qcerrinfoMem)))
			ThrowInternalError(hr);
		if (FAILED(hr = s_qcerrinfoMem->QueryInterface(IID_IErrorInfo,
			(LPVOID FAR*) &s_qerrinfoMem)))
		{
			// We should have plenty of memory as we start up components!
			ThrowInternalError(hr);
		}
		StrUni stuDesc(kstidOutOfMemory);
		s_qcerrinfoMem->SetDescription(stuDesc.Bstr());
		// We can't set the IID or source yet.
		s_qcerrinfoMem->SetHelpFile(const_cast<OLECHAR *>(GetModuleHelpFilePath().Chars()));
		s_qcerrinfoMem->SetHelpContext(khcidHelpOutOfMemory);
	}
Ejemplo n.º 2
0
/*----------------------------------------------------------------------------------------------
	General purpose method to set up and store an error, rather than throw an exception
	in the normal way.
----------------------------------------------------------------------------------------------*/
HRESULT StackDumper::RecordError(REFGUID iid, StrUni stuDescr, StrUni stuSource,
	int hcidHelpId, StrUni stuHelpFile)
{
	// We are going to make a new error info object.
	ICreateErrorInfoPtr qcerrinfo;
	IErrorInfoPtr qerrinfo;
	HRESULT hr;

	// If we can't get a new error object, the only documented cause is E_OUTOFMEMORY.
	if (FAILED(hr = ::CreateErrorInfo(&qcerrinfo)))
	{
		return E_OUTOFMEMORY;
	}
	if (FAILED(hr = qcerrinfo->QueryInterface(IID_IErrorInfo, (LPVOID FAR*) &qerrinfo)))
	{
		return E_UNEXPECTED;
	}

	hr = qcerrinfo->SetDescription(const_cast<OLECHAR *>(stuDescr.Chars()));
	if (FAILED(hr))
		return hr;
	hr = qcerrinfo->SetGUID(iid);
	if (FAILED(hr))
		return hr;
	hr = qcerrinfo->SetSource(const_cast<OLECHAR *>(stuSource.Chars()));
	if (FAILED(hr))
		return hr;
	hr = qcerrinfo->SetHelpFile(const_cast<OLECHAR *>(stuHelpFile.Chars()));
	if (FAILED(hr))
		return hr;
	if (!hcidHelpId)
		hcidHelpId = khcidNoHelpAvailable;
	hr = qcerrinfo->SetHelpContext(hcidHelpId);
	if (FAILED(hr))
		return hr;

	::SetErrorInfo(0, qerrinfo);
	return hr;
}