Example #1
0
STDMETHODIMP CEDBS_Linien::get_Item(VARIANT *vntIndexKey, VARIANT *pVal)
{
	USES_CONVERSION;
	AFX_MANAGE_STATE(AfxGetStaticModuleState())

 HRESULT hResult;
 CComObject<CEDBS_Linie> *pobjLinie;
 POSITION pos;
 IDispatch *pIObjekt;
 CString key;
 long lx;

	switch(vntIndexKey->vt) {
	case VT_I4|VT_BYREF:
		if( 0 < *vntIndexKey->plVal && *vntIndexKey->plVal <= mlstLinien.GetCount() ) {
			pos = mlstLinien.GetHeadPosition();
			lx = 0;
			while( lx != *vntIndexKey->plVal && pos != NULL ) {
				lx++;
				pobjLinie = (CComObject<CEDBS_Linie>*)mlstLinien.GetNext(pos);
			};
			if( lx == *vntIndexKey->plVal ) {
				hResult = pobjLinie->QueryInterface(IID_IDispatch,(void**)&pIObjekt);
				pVal->vt = VT_DISPATCH;
				pVal->pdispVal = pIObjekt;
				hResult = S_OK;
			}
			else
				hResult = S_FALSE;
		}
		else {
			hResult = S_FALSE;
		}
		break;
	default:
		ASSERT(0);
		hResult = S_FALSE;
		break;
	}
	return hResult;
}
Example #2
0
STDMETHODIMP CLHTMLWindow::showModalDialog(/*[in]*/ BSTR dialog, /*[in]*/ VARIANT *varArgIn, /*[in]*/ VARIANT *varOptions, /*[out,retval]*/ VARIANT *varArgOut)
{
	CComObject<CLHTMLDialog>* pHTMLDialog;
	CComObject<CLHTMLDialog>::CreateInstance(&pHTMLDialog);
	if (pHTMLDialog)
	{
		pHTMLDialog->AddRef();

#if 0
		CComPtr<ILDOMDocument> document;
		document.CoCreateInstance(&document);

		VARIANT_BOOL success;
		document->load(_variant_t(dialog), &success);
#endif

		pHTMLDialog->Release();
	}

	return S_OK;
}
Example #3
0
STDMETHODIMP CTextObject::EnumFormatEtc(DWORD dwDirection, IEnumFORMATETC** ppEnumFormatEtc)
{
	if (dwDirection != DATADIR_GET && dwDirection != DATADIR_SET)
		return E_INVALIDARG;
	typedef CComEnum<IEnumFORMATETC, &IID_IEnumFORMATETC, FORMATETC, _Copy<FORMATETC>, CComSingleThreadModel> CEnumFORMATETC;
	CComObject<CEnumFORMATETC>* pEnumerator;
	HRESULT hRes = CComObject<CEnumFORMATETC>::CreateInstance(&pEnumerator);
	if (FAILED(hRes))
		return hRes;
	static FORMATETC formats[] =
	{
		{ CF_TEXT, NULL, DVASPECT_CONTENT, -1, SUPPORTED_MEDIUM_TYPES },
		{ CF_UNICODETEXT, NULL, DVASPECT_CONTENT, -1, SUPPORTED_MEDIUM_TYPES }
	};
	hRes = pEnumerator->Init(formats, formats + countof(formats), this, ATL::AtlFlagNoCopy);
	if (SUCCEEDED(hRes))
		hRes = pEnumerator->QueryInterface(ppEnumFormatEtc);
	if (FAILED(hRes))
		delete pEnumerator;
	return hRes;
}
Example #4
0
/**************************************************************************
 *  IEnumIDList_Folder_Constructor
 *
 */
HRESULT IEnumIDList_Constructor(IEnumIDList **enumerator)
{
    CComObject<IEnumIDListImpl>                *theEnumerator;
    CComPtr<IEnumIDList>                    result;
    HRESULT                                    hResult;

    if (enumerator == NULL)
        return E_POINTER;
    *enumerator = NULL;
    ATLTRY (theEnumerator = new CComObject<IEnumIDListImpl>);
    if (theEnumerator == NULL)
        return E_OUTOFMEMORY;
    hResult = theEnumerator->QueryInterface(IID_PPV_ARG(IEnumIDList, &result));
    if (FAILED (hResult))
    {
        delete theEnumerator;
        return hResult;
    }
    *enumerator = result.Detach ();
    return S_OK;
}
HRESULT STDMETHODCALLTYPE CProjectItemInfo::CreateConfigurationParams(ItcProjectNode * AParentNode, ItcProjectNodeConfigurationInfo * * Value)
{
	HRESULT hr;

	// Get location path
	CComBSTR path = GetPath(AParentNode);

	// Choose the name
	CComBSTR name = GetName(AParentNode, 0);

	CComObject<CPluginConfiguration>* conf;
	hr = CComObject<CPluginConfiguration>::CreateInstance(&conf);
	if (FAILED(hr)) return hr;
  
	conf->Initialize( name,
	                  path,
	                  AParentNode,
	                  m_messenger );

	return conf->QueryInterface(Value);
}
STDMETHODIMP InterfaceAntiSpam::get_DNSBlackLists(IInterfaceDNSBlackLists **pVal)
{
   try
   {
      if (!m_pConfig)
         return GetAccessDenied();

      CComObject<InterfaceDNSBlackLists>* pDNSBlackListsInterface = new CComObject<InterfaceDNSBlackLists>();
      pDNSBlackListsInterface->SetAuthentication(m_pAuthentication);
      pDNSBlackListsInterface->LoadSettings();
   
      pDNSBlackListsInterface->AddRef();
      *pVal = pDNSBlackListsInterface;
   
      return S_OK;
   }
   catch (...)
   {
      return COMError::GenerateGenericMessage();
   }
}
HRESULT CAdminSession::FinalConstruct()
{
	// #define CAdminSession_TRACE_CONSTRUCTION
#ifdef CAdminSession_TRACE_CONSTRUCTION
	_TRACE_BEGIN
		DWORD id = GetCurrentThreadId();
	_TRACE_PART2("CAdminSession::FinalConstruct(): ThreadId = %d (0x%X)\n", id, id);
	_TRACE_PART1("\tRaw pointer = 0x%08X\n", this);
	_TRACE_END
#endif // CAdminSession_TRACE_CONSTRUCTION

		// Create the event sink object
		CComObject<CAdminSessionEventSink>* pEventSink = NULL;
	RETURN_FAILED(pEventSink->CreateInstance(&pEventSink));
	pEventSink->AddRef();
	pEventSink->Init(this);
	m_pEventSink = pEventSink;

	// Indicate success
	return S_OK;
}
Example #8
0
STDMETHODIMP CMixerControl::put_mux_type(MIX_LINE newVal)
{
    CComObject<CMixerLine>* pLine = 0;
    IMixerLine* pILine = 0;
    HRESULT hr = 0;

    pLine = m_pDest->GetLine(newVal);
    if(!pLine) return MIX_E_NOTFOUND;

    if(FAILED(hr = pLine->QueryInterface(IID_IMixerLine, (void**)&pILine)))
    {
        return hr;
    }

    hr = put_mux_source(pILine);

    pILine->Release();
    pILine = 0;

	return hr;
}
STDMETHODIMP InterfaceApplication::get_Diagnostics(IInterfaceDiagnostics **pVal)
{
    try
    {
        if (!authentication_->GetIsServerAdmin())
            return authentication_->GetAccessDenied();

        CComObject<InterfaceDiagnostics>* pInterfaceDiagnostics = new CComObject<InterfaceDiagnostics>;

        pInterfaceDiagnostics->SetAuthentication(authentication_);
        pInterfaceDiagnostics->AddRef();

        *pVal = pInterfaceDiagnostics;

        return S_OK;
    }
    catch (...)
    {
        return COMError::GenerateGenericMessage();
    }
}
STDMETHODIMP InterfaceAccounts::get_Item(long Index, IInterfaceAccount **pVal)
{
   try
   {
      if (!m_pAccounts)
         return GetAccessDenied();

      CComObject<InterfaceAccount>* pAccountInt = new CComObject<InterfaceAccount>();
      pAccountInt->SetAuthentication(m_pAuthentication);
   
      shared_ptr<HM::Account> pAccount = m_pAccounts->GetItem(Index);
   
      if (!pAccount)
         return DISP_E_BADINDEX;
      
      pAccountInt->AttachItem(pAccount);
      pAccountInt->AttachParent(m_pAccounts, true);
      pAccountInt->SetAuthentication(m_pAuthentication);
      pAccountInt->AddRef();
      *pVal = pAccountInt;
   
      return S_OK;
   }
   catch (...)
   {
      return COMError::GenerateGenericMessage();
   }
}
STDMETHODIMP InterfaceAccounts::Add(IInterfaceAccount **pVal)
{
   try
   {
      if (!m_pAccounts)
         return GetAccessDenied();

      if (!m_pAuthentication->GetIsDomainAdmin())
         return m_pAuthentication->GetAccessDenied();
   
      if (!m_pAccounts)
         return m_pAuthentication->GetAccessDenied();
   
      CComObject<InterfaceAccount>* pAccountInterface = new CComObject<InterfaceAccount>();
      pAccountInterface->SetAuthentication(m_pAuthentication);
   
      shared_ptr<HM::Account> pAccount = shared_ptr<HM::Account>(new HM::Account);
   
      pAccount->SetDomainID(m_iDomainID);
      
      pAccountInterface->AttachItem(pAccount);
      pAccountInterface->AttachParent(m_pAccounts, false);
      pAccountInterface->SetAuthentication(m_pAuthentication);
      pAccountInterface->AddRef();
   
      *pVal = pAccountInterface;
   
      return S_OK;
   }
   catch (...)
   {
      return COMError::GenerateGenericMessage();
   }
}
Example #12
0
STDMETHODIMP CEtsDivColl::CopyToWithWeight( DOUBLE dWeight, IEtsDivColl* pDest , IEtsDivColl** ppVal)
{
	__CHECK_POINTER(ppVal);
	HRESULT hr = S_OK;
	try
	{
		if (pDest == NULL)
		{
			CComObject<CEtsDivColl>* pCustDivs; 
			_CHK(CComObject<CEtsDivColl>::CreateInstance(&pCustDivs),  _T("Fail to create dividend object."));
			pCustDivs->AddRef();
			pDest = pCustDivs;
		}
		EnumIterType iter = m_DivColl.begin();
		EnumIterType iterEnd = m_DivColl.end();
		DOUBLE dDate = 0;
		DOUBLE dAmount = 0;
		for(;iter != iterEnd; ++iter)
		{
			dDate = iter->first;
			dAmount = iter->second;
			pDest->Add(dDate ,  (dAmount * dWeight) );
		}
		if(ppVal)
		{
			*ppVal = pDest;
			pDest->AddRef();
		}

	}
	catch (_com_error& e) 
	{
		hr =  Error((PTCHAR)EgLib::CComErrorWrapper::ErrorDescription(e), IID_IEtsDivColl, e.Error());
	}
	catch(...)
	{
		hr =  Error( _T("Unhandled exception handled at CopyToWithWeight"), IID_IEtsDivColl, E_FAIL);
	}
	return hr;
}
   String
   ScriptServer::Compile_(const String &sLanguage, const String &sFilename)
   {
      String sContents = FileUtilities::ReadCompleteTextFile(sFilename);

      if (sContents.IsEmpty())
         return "";

      // Create an instance of the script engine and execute the script.
      CComObject<CScriptSiteBasic>* pBasic;
      CComObject<CScriptSiteBasic>::CreateInstance(&pBasic);

      CComQIPtr<IActiveScriptSite> spUnk;

      if (!pBasic)
         return "ScriptServer:: Failed to create instance of script site.";

      spUnk = pBasic; // let CComQIPtr tidy up for us
      pBasic->Initiate(sLanguage, NULL);
      // pBasic->SetObjectContainer(pObjects);
      pBasic->AddScript(sContents);
      pBasic->Run();
      pBasic->Terminate();

      String sErrorMessage = pBasic->GetLastError();

      if (!sErrorMessage.IsEmpty())
         sErrorMessage = "File: " + sFilename + "\r\n" + sErrorMessage;

      return sErrorMessage;

   }
Example #14
0
STDMETHODIMP CMmVaOptRootColl::Add(LONG Key, BSTR SortKey, IMmVaOptRootAtom* Value, IMmVaOptRootAtom** pRetVal)
{
	try
	{
		if(!Value)
		{
			CComErrorWrapper::ThrowError(E_INVALIDARG, _T("Cann't insert empty option root."));
		}

		if(m_collRef.find(Key) != m_collRef.end())
		{
			CComErrorWrapper::ThrowError(E_INVALIDARG, _T("Option root with the same key is already exists."));
		}

		if(!Value)
		{
			CComObject<CMmVaOptRootAtom>* pNewVal;
			__CHECK_HRESULT(CComObject<CMmVaOptRootAtom>::CreateInstance(&pNewVal), _T("Fail to add option root."));
			pNewVal->AddRef();
			if(FAILED(IMmVaOptRootCollImpl::Add(Key, CComBSTR(SortKey), pNewVal)))
			{
				pNewVal->Release();
				CComErrorWrapper::ThrowError(E_INVALIDARG, _T("Fail to add option root."));
			}
			*pRetVal = pNewVal;
		}
		else
		{
			__CHECK_HRESULT(IMmVaOptRootCollImpl::Add(Key, CComBSTR(SortKey), Value), _T("Fail to add option root."));
			Value->AddRef();
			*pRetVal = Value;
		}
	}
	catch(const _com_error& e)
	{
		return Error((PTCHAR)CComErrorWrapper::ErrorDescription(e), IID_IMmVaOptRootColl, e.Error());
	}

	return S_OK;
}
Example #15
0
STDMETHODIMP InterfaceDomain::get_Accounts(IInterfaceAccounts **pVal)
{
   try
   {
      if (!m_pObject)
         return GetAccessDenied();

      CComObject<InterfaceAccounts>* pItem = new CComObject<InterfaceAccounts>();
      pItem->SetAuthentication(m_pAuthentication);
   
      shared_ptr<HM::Accounts> pAccounts;
   
      if (m_pAuthentication->GetIsDomainAdmin())
         pAccounts = m_pObject->GetAccounts();
      else
         pAccounts = m_pObject->GetAccounts(m_pAuthentication->GetAccountID());
   
      if (pAccounts)
      {
         pItem->SetAuthentication(m_pAuthentication);
         pItem->Attach(pAccounts);
         pItem->SetDomain(m_pObject->GetID());
         pItem->AddRef();
         *pVal = pItem;
      }
   
      return S_OK;
   }
   catch (...)
   {
      return COMError::GenerateGenericMessage();
   }
}
Example #16
0
void Flasher::InitShape()
{
   if (m_vdpoint.Size() == 0)
   {
      // First time shape has been set to custom - set up some points
      const float x = m_d.m_vCenter.x;
      const float y = m_d.m_vCenter.y;
      const float size = 100.0f;

      CComObject<DragPoint> *pdp;
      CComObject<DragPoint>::CreateInstance(&pdp);
      if (pdp)
      {
         pdp->AddRef();
         pdp->Init(this, x - size*0.5f, y - size*0.5f);
         pdp->m_fSmooth = false;
         m_vdpoint.AddElement(pdp);
      }
      CComObject<DragPoint>::CreateInstance(&pdp);
      if (pdp)
      {
         pdp->AddRef();
         pdp->Init(this, x - size*0.5f, y + size*0.5f);
         pdp->m_fSmooth = false;
         m_vdpoint.AddElement(pdp);
      }
      CComObject<DragPoint>::CreateInstance(&pdp);
      if (pdp)
      {
         pdp->AddRef();
         pdp->Init(this, x + size*0.5f, y + size*0.5f);
         pdp->m_fSmooth = false;
         m_vdpoint.AddElement(pdp);
      }
      CComObject<DragPoint>::CreateInstance(&pdp);
      if (pdp)
      {
         pdp->AddRef();
         pdp->Init(this, x + size*0.5f, y - size*0.5f);
         pdp->m_fSmooth = false;
         m_vdpoint.AddElement(pdp);
      }
   }
}
Example #17
0
STDMETHODIMP CComMine::get_Object(VARIANT index, LPDISPATCH* pVal)
{
	if (_pMine && pVal)
	{
		CComVariant var(index);
		if (SUCCEEDED(var.ChangeType(VT_I4)))
		{
			if (var.lVal < _pMine->GameInfo ().objects.count)
			{
				CComObject<CComObj>* pObject = new CComObject<CComObj>();
				pObject->_pObject = &_pMine->Objects ()[var.lVal];
				
				if (SUCCEEDED(pObject->QueryInterface(IID_IDispatch,(void**)pVal)))
				{
					return S_OK;
				}
				delete pObject;
			}
		}
	}
	return E_FAIL;
}
Example #18
0
STDMETHODIMP CMmRpUndColl::Add(BSTR Key, IMmRpUndAtom* Value, IMmRpUndAtom** pRetVal)
{
	__CHECK_POINTER(pRetVal);

	try
	{
		_bstr_t bsKey(Key);
		if(m_coll.find(bsKey) != m_coll.end())
		{
			CComErrorWrapper::ThrowError(E_INVALIDARG, _T("Value with the same key already exists."));
		}

		CComObject<CMmRpUndAtom>* pUnd;

		if(!Value)
		{
			__CHECK_HRESULT(CComObject<CMmRpUndAtom>::CreateInstance(&pUnd), _T("Failed to add value."));
			pUnd->AddRef();
			if(FAILED(IMmRpUndCollImpl::Add(bsKey, pUnd)))
			{
				pUnd->Release();
				CComErrorWrapper::ThrowError(E_INVALIDARG, _T("Failed to add value."));
			}
			*pRetVal = pUnd;
		}
		else
		{
			__CHECK_HRESULT(IMmRpUndCollImpl::Add(bsKey, Value), _T("Failed to add value."));
			Value->AddRef();
			*pRetVal = Value;
		}
	}
	catch(const _com_error& e)
	{
		return Error((PTCHAR)CComErrorWrapper::ErrorDescription(e), IID_IMmRpUndColl, e.Error());
	}

	return S_OK;
}
CTypeDBI *CDBIContext::GetSimpleType (BL_IEC_TYP iecType)
{
    HRESULT hr;
    CComObject<CTypeDBI> *pType;

    if (m_SimpleTypes[iecType] != NULL)
    {
        CTypeDBI *pTypeDBI;

        pTypeDBI = m_SimpleTypes[iecType];
        pTypeDBI->AddRef ();
        return (pTypeDBI);
    };

    hr = CComObject<CTypeDBI>::CreateInstance (&pType);
    ASSERT (SUCCEEDED (hr));
    if (FAILED (hr))
    {
        return (NULL);
    };
    ASSERT (pType != NULL);
    if (pType == NULL)
    {
        return (NULL);
    };

    pType->AddRef ();

    hr = pType->Init (this, iecType);
    ASSERT (SUCCEEDED (hr));
    if (FAILED (hr))
    {
        pType->Release ();
        return (NULL);
    };

    m_SimpleTypes[iecType] = pType;
    return (pType);
}
Example #20
0
STDMETHODIMP CDlrComServer::get__NewEnum(IUnknown** ppUnk)
{
     if (ppUnk == NULL)
        return E_POINTER;
    *ppUnk = NULL;

    CComObject<VariantComEnum>* pEnum = NULL;
    HRESULT hr = CComObject<VariantComEnum>::CreateInstance(&pEnum);

    if (FAILED(hr))
        return hr;

    hr = pEnum->Init(&m_arr[0], &m_arr[NUMELEMENTS], reinterpret_cast<IUnknown*>(this), AtlFlagNoCopy);

    if (SUCCEEDED(hr))
        hr = pEnum->QueryInterface(ppUnk);

    if (FAILED(hr))
        delete pEnum;

    return hr;
}
STDMETHODIMP CBuiltinDatatypeLibrary::CreateDatatypeBuilder( BSTR typeName, IDatatypeBuilder** ppRetVal )
{
	IDatatype* pDatatype;
	HRESULT hr = CreateDatatype(typeName,&pDatatype);
	if(FAILED(hr))
	{// the type name was wrong.
		*ppRetVal = NULL;
		return hr;
	}

	CComObject<CDatatypeBuilderImpl>* p;

	hr = CComObject<CDatatypeBuilderImpl>::CreateInstance(&p);
	if(FAILED(hr))	return hr;

	// no need to call AddRef here.
	p->m_pDatatype = pDatatype;

	p->AddRef();
	*ppRetVal = p;
	return hr;
}
Example #22
0
STDMETHODIMP CComMine::get_Cube(VARIANT index, LPDISPATCH *pVal)
{
	if (_pMine && pVal)
	{
		CComVariant var(index);
		if (SUCCEEDED(var.ChangeType(VT_I4)))
		{
			if (var.lVal < _pMine->SegCount ())
			{
				CComObject<CComCube>* pCube = new CComObject<CComCube>();
				pCube->_pCube = &_pMine->Segments ()[var.lVal];
				
				if (SUCCEEDED(pCube->QueryInterface(IID_IDispatch,(void**)pVal)))
				{
					return S_OK;
				}
				delete pCube;
			}
		}
	}
	return E_FAIL;
}
Example #23
0
STDMETHODIMP CEtsContractBySymColl::Add(BSTR Key, IEtsContractAtom* Value, IEtsContractAtom** pRetVal)
{
	__CHECK_POINTER(pRetVal);

	try
	{
		if(m_coll.find(CComBSTR(Key)) != m_coll.end())
		{
			EgLib::CComErrorWrapper::ThrowError(E_INVALIDARG, _T("Contract with the same key is already exists."));
		}

		if(!Value)
		{
			CComObject<CEtsContractAtom>* pNewVal;

			_CHK(CComObject<CEtsContractAtom>::CreateInstance(&pNewVal), _T("Fail to add contract."));
			pNewVal->AddRef();
			if(FAILED(IEtsContractBySymCollImpl::Add(Key, pNewVal)))
			{
				pNewVal->Release();
				EgLib::CComErrorWrapper::ThrowError(E_INVALIDARG, _T("Fail to add contract."));
			}
			*pRetVal = pNewVal;
		}
		else
		{
			_CHK(IEtsContractBySymCollImpl::Add(Key, Value), _T("Fail to add contract."));
			Value->AddRef();
			*pRetVal = Value;
		}
	}
	catch(const _com_error& e)
	{
		return Error((PTCHAR)EgLib::CComErrorWrapper::ErrorDescription(e), IID_IEtsContractBySymColl, e.Error());
	}

	return S_OK;
}
Example #24
0
STDMETHODIMP CMmOrderByReqColl::Add(BSTR Key, DATE SortKey, IMmOrderAtom* Value, IMmOrderAtom** pRetVal)
{
	__CHECK_POINTER(pRetVal);

	try
	{
		_bstr_t bsKey(Key);
		if(m_collRef.find(bsKey) != m_collRef.end())
		{
			EgLib::CComErrorWrapper::ThrowError(E_INVALIDARG, _T("Order with the same key already exists."));
		}

		if(!Value)
		{
			CComObject<CMmOrderAtom>* pNewVal;
			__CHECK_HRESULT(CComObject<CMmOrderAtom>::CreateInstance(&pNewVal), _T("Failed to add order."));
			pNewVal->AddRef();
			if(FAILED(IMmOrderByReqCollImpl::Add(bsKey, SortKey, pNewVal)))
			{
				pNewVal->Release();
				EgLib::CComErrorWrapper::ThrowError(E_INVALIDARG, _T("Failed to add order."));
			}
			*pRetVal = pNewVal;
		}
		else
		{
			__CHECK_HRESULT(IMmOrderByReqCollImpl::Add(bsKey, SortKey, Value), _T("Failed to add order."));
			Value->AddRef();
			*pRetVal = Value;
		}
	}
	catch(const _com_error& e)
	{
		return Error((PTCHAR)EgLib::CComErrorWrapper::ErrorDescription(e), IID_IMmOrderByReqColl, e.Error());
	}

	return S_OK;
}
Example #25
0
STDMETHODIMP CExtraResponseData::EnumerateExtraHeaders(IUOLFoneClientHeaderInfoEnum** ppHeaderInfoEnum)
{
	HRESULT hr = E_FAIL;

	CComObject<CHeaderInfoEnum>* pNewHeaderInfoEnum;

	hr = CComObject<CHeaderInfoEnum>::CreateInstance(&pNewHeaderInfoEnum);

	if (SUCCEEDED(hr))
	{
		for (POSITION pos = m_listHeaderData.GetHeadPosition(); pos; )
		{
			CHeaderDataPtr pHeaderData = m_listHeaderData.GetNext(pos);

			CComObject<CHeaderInfo>* pHeaderInfo;

			hr = CComObject<CHeaderInfo>::CreateInstance(&pHeaderInfo);

			if (SUCCEEDED(hr))
			{
				pHeaderInfo->SetHeaderData(pHeaderData);
				pNewHeaderInfoEnum->AddHeaderInfo(pHeaderInfo);
			}
			else
			{
				break;
			}
		}

		if (SUCCEEDED(hr))
		{
			pNewHeaderInfoEnum->AddRef();
			*ppHeaderInfoEnum = pNewHeaderInfoEnum;
		}
	}

	return hr;
}
Example #26
0
int Run(bool bAutomation, LPTSTR /*lpstrCmdLine*/ = NULL, int nCmdShow = SW_SHOWDEFAULT)
{
	CComObject<CPageDesignerApp>* app;
	CComObject<CPageDesignerApp>::CreateInstance(&app);
	app->AddRef();
	gApp = app;
	gIApp = app;

	int nRet;

	if (bAutomation)
	{
		CMessageLoop theLoop;
		_Module.AddMessageLoop(&theLoop);	// ??

		nRet = theLoop.Run();

		_Module.RemoveMessageLoop();	// ??
	}
	else
	{
		CMessageLoop theLoop;
		_Module.AddMessageLoop(&theLoop);

		long result;
		app->Run(&result);

		_Module.Lock();

		nRet = theLoop.Run();

		_Module.RemoveMessageLoop();
	}

	app->Release();

	return nRet;
}
Example #27
0
STDMETHODIMP CMmVaExpColl::Add(DATE Key, IMmVaExpAtom* Value, IMmVaExpAtom** pRetVal)
{
	__CHECK_POINTER(pRetVal);

	try
	{
		if(m_coll.find(Key) != m_coll.end())
		{
			CComErrorWrapper::ThrowError(E_INVALIDARG, _T("Expiry with the same key is already exists."));
		}

		CComObject<CMmVaExpAtom>* pExp;

		if(!Value)
		{
			__CHECK_HRESULT(CComObject<CMmVaExpAtom>::CreateInstance(&pExp), _T("Fail to add expiry."));
			pExp->AddRef();
			if(FAILED(IMmVaExpCollImpl::Add(Key, pExp)))
			{
				pExp->Release();
				CComErrorWrapper::ThrowError(E_INVALIDARG, _T("Fail to add expiry."));
			}
			*pRetVal = pExp;
		}
		else
		{
			__CHECK_HRESULT(IMmVaExpCollImpl::Add(Key, Value), _T("Fail to add expiry."));
			Value->AddRef();
			*pRetVal = Value;
		}
	}
	catch(const _com_error& e)
	{
		return Error((PTCHAR)CComErrorWrapper::ErrorDescription(e), IID_IMmVaExpColl, e.Error());
	}

	return S_OK;
}
STDMETHODIMP CMmTntCounterPartyByNameColl::Add(BSTR Key, IMmTntCounterPartyAtom* Value, IMmTntCounterPartyAtom** pRetVal)
{
	__CHECK_POINTER(pRetVal);

	try
	{
		if(m_coll.find(CComBSTR(Key)) != m_coll.end())
		{
			EgLib::CComErrorWrapper::ThrowError(E_INVALIDARG, _T("Counterparty with the same key already exists"));
		}

		CComObject<CMmTntCounterPartyAtom>* pExp;

		if(!Value)
		{
			__CHECK_HRESULT(CComObject<CMmTntCounterPartyAtom>::CreateInstance(&pExp), _T("Failed to add counterparty"));
			pExp->AddRef();
			if(FAILED(IMmTntCounterPartyByNameCollImpl::Add(Key, pExp)))
			{
				pExp->Release();
				EgLib::CComErrorWrapper::ThrowError(E_INVALIDARG, _T("Failed to add counterparty"));
			}
			*pRetVal = pExp;
		}
		else
		{
			__CHECK_HRESULT(IMmTntCounterPartyByNameCollImpl::Add(Key, Value), _T("Failed to add counterparty"));
			Value->AddRef();
			*pRetVal = Value;
		}
	}
	catch(const _com_error& e)
	{
		return Error((PTCHAR)EgLib::CComErrorWrapper::ErrorDescription(e), IID_IMmTntCounterPartyByNameColl, e.Error());
	}

	return S_OK;
}
Example #29
0
// IASModel
STDMETHODIMP ASDTDModel::createASContentModel(/*[in]*/ unsigned long minOccurs, /*[in]*/ unsigned long maxOccurs, /*[in]*/ ASContentModelTypeOp listOperator, /*[out,retval]*/ IASContentModel** pVal)
{
    if (pVal == NULL) return E_POINTER;

    CComObject<CASDTDContentModel>* pContentModel;
    HRESULT hr = CComObject<CASDTDContentModel>::CreateInstance(&pContentModel);
    if (SUCCEEDED(hr))
    {
        pContentModel->AddRef();

        pContentModel->m_minOccurs = minOccurs;
        pContentModel->m_maxOccurs = maxOccurs;
        pContentModel->m_listOperator = listOperator;

        *pVal = pContentModel;
    }
    else
    {
        *pVal = NULL;
    }

    return S_OK;
}
Example #30
-2
// GetDispatch --------------------------------------------------------------
LPDISPATCH CCodeListCtrl::GetDispatch()
{
#ifdef _ACTIVEX

   if( NULL == m_lpDispatch )
   {
      CComObject<CICodeList>* pNew = NULL;
      HRESULT hR = pNew->CreateInstance( &pNew );

      if( SUCCEEDED( hR ) )
      {
         pNew->AddRef();
         pNew->SetControl( this );
         m_lpDispatch = pNew;
      }
   }

#endif//#ifdef _ACTIVEX

   return m_lpDispatch;
}