本文整理汇总了C++中THROW_FAILED_HRESULT函数的典型用法代码示例。如果您正苦于以下问题:C++ THROW_FAILED_HRESULT函数的具体用法?C++ THROW_FAILED_HRESULT怎么用?C++ THROW_FAILED_HRESULT使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了THROW_FAILED_HRESULT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: refcnt_ToolBarButton
// ----------------------------------------------------------------------------
// refcnt_ToolBarButton
// ----------------------------------------------------------------------------
void refcnt_ToolBarButton (ebHTHREAD hThread, int iNumArgs, ebARGS lpArgs)
{
BASIC_OP_TRACE_SYS(refcnt_GeoObjects);
switch (iNumArgs) {
case OBJECT_REFNEW:
{
ebSetObject (lpArgs, 0, NULL); // für alle Fälle
try {
WDControlToolBarButton ToolBarBttn(CLSID_TRiASToolBarButton);
WDispatch Disp;
THROW_FAILED_HRESULT(((OLE2AutoExtension *)g_pTE) -> App() -> GetDispatchIF (Disp.ppi()));
THROW_FAILED_HRESULT(ToolBarBttn -> put_Application (Disp));
THROW_FAILED_HRESULT(ToolBarBttn -> put_Parent (Disp));
ebSetObject (lpArgs, 0, (DWORD)ToolBarBttn.detach());
} catch (_com_error&) {
return;
}
}
break;
case OBJECT_REFINC:
((IUnknown *)ebGetObject (lpArgs, 1)) -> AddRef();
break;
case OBJECT_REFDEC:
((IUnknown *)ebGetObject (lpArgs, 1)) -> Release();
break;
}
}
示例2: _ASSERTE
STDMETHODIMP COleObjectPropertyDual::SearchObjects(BSTR bstrToMatch,
SEARCHMODE rgFlags, IEnumObjectsByNumber **ppvObj)
{
if (NULL == ppvObj)
return E_POINTER;
*ppvObj = NULL;
_ASSERTE(m_fSearchAble); // muß suchen können
COM_TRY {
WDSearchAbleObjectProperty Search(m_ObjProp);
WDGeoObjects Objs;
THROW_FAILED_HRESULT(Search -> SearchObjects(bstrToMatch,
GetSearchMode(rgFlags), Objs.ppi()));
WQueryEnumLONG QueryEnum(Objs);
WEnumLONG Enum;
THROW_FAILED_HRESULT(QueryEnum -> QueryEnumLONG (Enum.ppi()));
WEnumObjectsByNumber EnumObjs(Enum);
*ppvObj = EnumObjs.detach();
} COM_CATCH;
return S_OK;
}
示例3: THROW_FAILED_HRESULT
///////////////////////////////////////////////////////////////////////////////
// IPropertyAction2 methods
STDMETHODIMP CPropertyAction::InitFromData (IDataObject *pIDO, BOOL fCreate, DWORD)
{
if (NULL == pIDO) {
if (fCreate)
return S_OK; // can attempt to initialize it self
else
return S_FALSE; // can't attempt to replace internal data
}
COM_TRY {
CComVariant vData;
THROW_FAILED_HRESULT(GetVariantData (pIDO, &c_feInitPropAct, &vData));
THROW_FAILED_HRESULT(vData.ChangeType(VT_BSTR));
WParseStringPairs Bag (CLSID_ParseStringPairs);
CComVariant v (DISP_E_PARAMNOTFOUND, VT_ERROR); // no error log
LONG lCount = 0;
CComBSTR bstrData;
if (*V_BSTR(&vData) != L';') // Data müssen mit ";PropActData" anfangen
bstrData = L";PropActData;";
bstrData += V_BSTR(&vData);
THROW_FAILED_HRESULT(Bag -> put_Pattern (CComBSTR(L";%1=%2")));
THROW_FAILED_HRESULT(Bag -> Parse (V_BSTR(&vData), &lCount));
THROW_FAILED_HRESULT(Bag -> InitObject (GetUnknown(), v));
} COM_CATCH;
return S_OK;
}
示例4: GetHWNDData
// Lesen eines EnumLONG aus einem DataObjekt ----------------------------------
HRESULT GetHWNDData (IDataObject *pIDataObj, HWND *phWnd)
{
HRESULT hr = E_FAIL;
STGMEDIUM stg;
memset (&stg, 0, sizeof(STGMEDIUM));
try {
// Testen, ob das gewünschte Format überhaupt da ist
THROW_FAILED_HRESULT(pIDataObj -> QueryGetData ((FORMATETC *)&c_feObjectWindow));
// Daten vom DataObject geben lassen
THROW_FAILED_HRESULT(pIDataObj -> GetData ((FORMATETC *)&c_feObjectWindow, &stg));
// HWND aus STGMEDIUM herauskopieren
HWND *phWndGlobal = (HWND *)GlobalLock (stg.hGlobal);
if (NULL == phWndGlobal)
_com_issue_error(E_UNEXPECTED);
*phWnd = *phWndGlobal;
ReleaseStgMedium (&stg);
} catch (_com_error &e) {
if (TYMED_NULL != stg.tymed)
ReleaseStgMedium (&stg);
return _COM_ERROR(e);
}
return NOERROR;
}
示例5: PropertySequence_refcnt
// ----------------------------------------------------------------------------
// PropertySequence_refcnt
// ----------------------------------------------------------------------------
void PropertySequence_refcnt (ebHTHREAD hThread, int iNumArgs, ebARGS lpArgs)
{
BASIC_OP_TRACE_SYS(PropertySequence_refcnt);
switch (iNumArgs) {
case OBJECT_REFNEW:
{
ebSetObject (lpArgs, 0, NULL); // für alle Fälle
try {
WPropertyActionSequence PropSeq (CLSID_PropertyActionSequence); // throws hr
HPROJECT hPrCtx = reinterpret_cast<HPROJECT>(ebThread_GetLong (hThread, SETLONG_HPROJECT)); // Kontext-Datenquelle
ebSetObject (lpArgs, 0, (DWORD)PropSeq.detach());
if (HACTCONNECTION != hPrCtx) {
WDataObject CtxDO;
CComVariant vData (reinterpret_cast<long>(hPrCtx), VT_I4);
THROW_FAILED_HRESULT(PropSeq -> GetSequenceContext (CtxDO.ppi()));
THROW_FAILED_HRESULT(SetVariantData (vData, CtxDO, &c_feDataSourceHandle));
}
} catch (...) {
TRACE("Couldn't instantiate PropertyActionSequence\r\n");
}
}
break;
case OBJECT_REFINC:
((IUnknown *)ebGetObject(lpArgs, 1)) -> AddRef();
break;
case OBJECT_REFDEC:
((IUnknown *)ebGetObject(lpArgs, 1)) -> Release();
break;
}
}
示例6: while
HRESULT CAddFunctionDlg::FillComboBox()
{
HRESULT hr = NOERROR;
int iResID = IDR_NOTIFCLOSING;
try
{
while (iResID != IDR_NOTIFEND)
{
CTemplateManagement *pTM = new CTemplateManagement;
THROW_FAILED_HRESULT(pTM -> Load(iResID, "Notification"));
char str[MAXSTRLENGTH];
THROW_FAILED_HRESULT(pTM -> GetName(str, MAXSTRLENGTH));
int i = m_cbxNotification.AddString(str);
if (i == CB_ERRSPACE) _com_issue_error(E_OUTOFMEMORY);
if (i == CB_ERR) _com_issue_error(E_FAIL);
m_cbxNotification.SetItemData(i, (DWORD) pTM);
iResID++;
}
}
catch(_com_error& e)
{
hr = _COM_ERROR(e);
}
return hr;
}
示例7: pt
char * CCoordTransService::CoordTransToStringEx (
double dX, double dY, bool isX, char *pBuffer, int iLen)
{
if (m_fIsInitialized) {
try {
CComBSTR bstr;
CCSPoint pt (dX, dY);
if (isX) {
THROW_FAILED_HRESULT(m_CTF -> ToStrings (&pt, &bstr, NULL, NULL));
} else {
THROW_FAILED_HRESULT(m_CTF -> ToStrings (&pt, NULL, &bstr, NULL));
}
USES_CONVERSION;
iLen = min(bstr.Length(), iLen-1);
strncpy (pBuffer, OLE2A(bstr), iLen);
pBuffer[iLen] = '\0';
return pBuffer;
} catch (_com_error &e) {
ShowError (_COM_ERROR(e), IDS_CSSERRORCAPTION, g_cbCoordTransToStringEx);
return NULL;
}
}
ShowError (TRIAS02_E_CSSNOTINITIALIZED, IDS_CSSERRORCAPTION, g_cbCoordTransToStringEx);
return NULL;
}
示例8: THROW_FAILED_HRESULT
bool CSelectCoordSysActionDlg::PrepareResult()
{
// Selektierten Eintrag holen
HTREEITEM hItem = m_tvCoordSystems.GetSelectedItem();
if (NULL == hItem || m_tvCoordSystems.ItemHasChildren (hItem))
return false; // nur Childs behandeln
CCoordSystemItem *pItemData = (CCoordSystemItem *)m_tvCoordSystems.GetItemData (hItem);
if (NULL == pItemData)
return false;
// Koordinatensystem am Parent setzen
CString strTcfName = pItemData->GetTcfName();
COM_TRY {
CComQIPtr<ITRiASCS, &IID_ITRiASCS> CS;
THROW_FAILED_HRESULT(CS.CoCreateInstance(CLSID_TRIASCS));
THROW_FAILED_HRESULT(CS -> LoadFromFile(CComBSTR(strTcfName)));
m_CS = CS; // store result coordsystem
} COM_CATCH_OP_RETURN(CantLoadCS(strTcfName), false);
return true;
}
示例9: CreateStreamOnHGlobalFromIUnknown
// Serialisieren/DeSerialisieren eines IUnknowns
// in diesem Falle ein IDataObject
HRESULT CreateStreamOnHGlobalFromIUnknown (
IUnknown *pIUnk, REFCLSID rClsID, IStream **ppIStream)
{
ASSERT(NULL != pIUnk);
ASSERT(NULL != ppIStream);
*ppIStream = NULL;
try {
// neuen Stream anlegen, kreiert eine neuen Memoryblock der Größe NULL
// wird selbstständig wieder freigegen (true)
WStream IStream;
THROW_FAILED_HRESULT(CreateStreamOnHGlobal (NULL, true, IStream.ppi()));
// den Enumerator wegschreiben
WPersistStream IPersStr (pIUnk); // throws hr
THROW_FAILED_HRESULT(OleSaveToStream (IPersStr, IStream));
// wieder zurück positionieren
LARGE_INTEGER li;
LISet32 (li, 0L);
THROW_FAILED_HRESULT(IStream -> Seek (li, STREAM_SEEK_SET, NULL));
*ppIStream = IStream.detach();
}
catch (_com_error &e)
{
return _COM_ERROR(e);
}
return S_OK;
}
示例10: GetVariantData
HRESULT GetVariantData (IDataObject *pIDO, const FORMATETC *pcfe, CComVariant *pv)
{
if (NULL == pIDO) return E_POINTER;
STGMEDIUM stg;
memset (&stg, 0, sizeof(STGMEDIUM));
try {
// Testen, ob das gewünschte Format überhaupt da ist
HRESULT hr = pIDO -> QueryGetData ((FORMATETC *)pcfe);
if (S_OK != hr) return hr; // Format nicht vorhanden
if (NULL == pv) return S_OK; // nur nachfragen
// Daten vom DataObject geben lassen
THROW_FAILED_HRESULT(pIDO -> GetData ((FORMATETC *)pcfe, &stg));
// einlesen des Enumerators aus den erhaltenen STGMEDIUM
THROW_FAILED_HRESULT(pv -> ReadFromStream (stg.pstm));
ReleaseStgMedium (&stg);
} catch (_com_error& hr_result) {
if (TYMED_NULL != stg.tymed)
ReleaseStgMedium (&stg);
return _COM_ERROR(hr_result);
}
return S_OK;
}
示例11: GetStringData
// Dient zum Lesen der Daten (EnumLONG) vom Stream im Datenobjekt
HRESULT GetStringData (IDataObject *pIDataObj, LPSTR lpstr, int iLen)
{
HRESULT hr = NOERROR;
STGMEDIUM stg;
memset (&stg, 0, sizeof(STGMEDIUM));
try
{
// Testen, ob das gewünschte Format überhaupt da ist
THROW_FAILED_HRESULT(pIDataObj -> QueryGetData ((FORMATETC *)&c_feInitPropAct));
// Daten vom DataObject geben lassen
THROW_FAILED_HRESULT(pIDataObj -> GetData ((FORMATETC *)&c_feInitPropAct, &stg));
// Einlesen des CComVariants aus den erhaltenen STGMEDIUM-Stream stg.pstm
THROW_FAILED_HRESULT(CreateStringFromStream (stg.pstm, lpstr, iLen));
// Freigeben Storagemedium
ReleaseStgMedium (&stg);
}
catch (_com_error& e)
{
if (TYMED_NULL != stg.tymed)
ReleaseStgMedium (&stg);
return _COM_ERROR(e);
}
return hr;
}
示例12: GetEnumLONGData
// Dient zum Lesen der Daten (EnumLONG) vom Stream im Datenobjekt
HRESULT GetEnumLONGData (IDataObject *pIDataObj, IEnum<LONG> **ppIEnumOut)
{
if (NULL == pIDataObj)
return S_FALSE;
HRESULT hr = ResultFromScode (E_FAIL);
STGMEDIUM stg;
memset (&stg, 0, sizeof(STGMEDIUM));
try {
// Testen, ob das gewünschte Format überhaupt da ist
THROW_FAILED_HRESULT(pIDataObj -> QueryGetData ((FORMATETC *)&c_feSelectedObjects));
// Daten vom DataObject geben lassen
THROW_FAILED_HRESULT(pIDataObj -> GetData ((FORMATETC *)&c_feSelectedObjects, &stg));
// Einlesen des Enumerators aus den erhaltenen STGMEDIUM
THROW_FAILED_HRESULT(CreateEnumLONGFromStream (stg.pstm, ppIEnumOut));
ReleaseStgMedium (&stg);
} catch (_com_error &e) {
if (TYMED_NULL != stg.tymed)
ReleaseStgMedium (&stg);
return _COM_ERROR(e);
}
return NOERROR;
}
示例13: THROW_FAILED_HRESULT
// --------------------------------------------------------------------------------------------
STDMETHODIMP CRegOperatPropAct::BeginAction (IProgressIndicator* pIProgInd)
{
#if _TRiAS_VER < 0x0300
m_hPr = 0;
#else
COM_TRY
{
// Zieldatenquelle aus KontextObjekt herausfinden
WPropertyActionSequence wSeq;
WDataObject CtxDO;
CComVariant vData;
m_hPr = 0;
THROW_FAILED_HRESULT (GetSite (IID_IPropertyActionSequence, wSeq.ppv()));
THROW_FAILED_HRESULT (wSeq->GetSequenceContext (CtxDO.ppi()));
if (SUCCEEDED (GetVariantData (CtxDO, &c_feDataSourceHandle, &vData)) &&
SUCCEEDED (vData.ChangeType (VT_I4)))
{
m_hPr = reinterpret_cast<HPROJECT>(V_I4(&vData));
}
}
COM_CATCH;
#endif // _TRiAS_VER < 0x0300
// Zustand des Dialogs retten (für evtl. späteres Save())
m_pRegOperDlg->GetSelectedInfo (&m_caSelInfo, m_bIsDirty);
// Liste für Objekte, die an die PropertyPage übergeben werden, initialisieren
m_InObjs.clear(); // Liste sicher leeren
m_ObjsIter = m_InObjs.begin(); // auf Anfang stellen
return S_OK;
} // BeginAction
示例14: bstr
HRESULT CCoordTransService::FindCTF (void)
{
USES_CONVERSION;
char cbCTFName[_MAX_PATH];
CComBSTR bstr (GetProperty (m_Props, g_cbCoordTransform, A2OLE(g_cbDefault)));
strcpy (cbCTFName, OLE2A(bstr));
if (!stricmp (cbCTFName, g_cbDefault))
m_fIsDefault = true;
// CTFService's über CATID enumerieren, CTFService wiederfinden
try {
WEnumGUID EnumGuids; // Enumerator der CTFService-Objekte
WCatInformation CatInfo (CLSID_StdComponentCategoriesMgr); // throws hr
GUID guidImpl[1];
guidImpl[0] = CATID_TRiASCoordsystem;
THROW_FAILED_HRESULT(CatInfo -> EnumClassesOfCategories (1, guidImpl, 0, NULL, EnumGuids.ppi()));
GUID guid;
LPOLESTR lpGuid = NULL;
bool fFoundGuid = false;
for (EnumGuids -> Reset(); S_OK == EnumGuids -> Next (1, &guid, NULL); /**/)
{
THROW_FAILED_HRESULT(StringFromCLSID (guid, &lpGuid));
CClassesRoot regClsID (OLE2A(lpGuid));
char cbBuffer[_MAX_PATH];
LONG lSize = sizeof(cbBuffer);
if (NULL != lpGuid) {
CoTaskMemFree (lpGuid);
lpGuid = NULL;
}
if (regClsID.isValid() && regClsID.GetSZ (g_cbOldName, cbBuffer, lSize))
{
if (!stricmp (cbBuffer, cbCTFName)) {
fFoundGuid = true;
m_strCTF = cbBuffer;
break;
}
}
}
if (!fFoundGuid) {
TX_ASSERT(fFoundGuid);
return E_FAIL; // snh!
}
} catch (_com_error &e) {
TX_ASSERT(S_OK == _COM_ERROR(e));
return _COM_ERROR(e);
}
return S_OK;
}
示例15: PropertySequence_cmd_AddAction
void PropertySequence_cmd_AddAction (ebHTHREAD hThread, int iNumArgs, ebARGS lpArgs)
{
BASIC_OP_TRACE(PropertySequence_cmd_AddAction);
WPropertyActionSequence Seq ((IPropertyActionSequence *)ebGetObject (lpArgs, 1));
ebHSUB hStr = ebGetString (lpArgs, 2);
if (NULL != hStr) {
USES_CONVERSION;
LPSTR lpstr = ebLockString (hThread, hStr);
BASIC_OP_TRACE2(lpstr);
CLSID clsID;
HRESULT hr = CLSIDFromString (A2OLE(lpstr), &clsID);
if (FAILED(hr))
hr = CLSIDFromProgID (A2OLE(lpstr), &clsID);
if (SUCCEEDED(hr)) {
CComVariant v2 (MakeVARIANT (hThread, iNumArgs, lpArgs, 3));
if (VT_ERROR == V_VT(&v2)) {
// nur ein Parameter gegeben
CALPCLSID cal;
const CLSID *pClsID = &clsID;
memset(&cal, '\0', sizeof(CALPCLSID));
cal.cElems = 1;
cal.ppElems = &pClsID;
Seq -> AddActionsByCLSID (&cal);
} else {
// 2. Parameter auswerten
try {
WPropertyAction WAct (clsID); // throws hr
if (FAILED(InitFromData (WAct, v2))) {
// kann nicht mit Daten initialisiert werden, also normales Init
WPersistStreamInit Init (WAct); // throws hr
THROW_FAILED_HRESULT(Init -> InitNew());
}
THROW_FAILED_HRESULT(Seq -> AddAction (WAct));
} catch (_com_error&) {
;
}
}
}
ebUnlockString (hThread, hStr);
}
}