本文整理汇总了C++中ExitOnNull函数的典型用法代码示例。如果您正苦于以下问题:C++ ExitOnNull函数的具体用法?C++ ExitOnNull怎么用?C++ ExitOnNull使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ExitOnNull函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WcaGetRecordFormattedString
/********************************************************************
WcaGetRecordFormattedString() - gets formatted string filed from record
********************************************************************/
extern "C" HRESULT WIXAPI WcaGetRecordFormattedString(
__in MSIHANDLE hRec,
__in UINT uiField,
__inout LPWSTR* ppwzData
)
{
if (!hRec || !ppwzData)
{
return E_INVALIDARG;
}
HRESULT hr = S_OK;
UINT er;
DWORD_PTR cch = 0;
PMSIHANDLE hRecFormat;
// get the format string
hr = WcaGetRecordString(hRec, uiField, ppwzData);
ExitOnFailure(hr, "failed to get string from record");
if (!**ppwzData)
{
ExitFunction();
}
// hide the nulls '[~]' so we can get them back after formatting
HideNulls(*ppwzData);
// set up the format record
hRecFormat = ::MsiCreateRecord(1);
ExitOnNull(hRecFormat, hr, E_UNEXPECTED, "Failed to create record to format string");
hr = WcaSetRecordString(hRecFormat, 0, *ppwzData);
ExitOnFailure(hr, "failed to set string to format record");
// format the string
hr = StrMaxLength(*ppwzData, &cch);
ExitOnFailure(hr, "failed to get max length of string");
er = ::MsiFormatRecordW(WcaGetInstallHandle(), hRecFormat, *ppwzData, (DWORD*)&cch);
if (ERROR_MORE_DATA == er)
{
hr = StrAlloc(ppwzData, ++cch);
ExitOnFailure(hr, "Failed to allocate memory for record string");
er = ::MsiFormatRecordW(WcaGetInstallHandle(), hRecFormat, *ppwzData, (DWORD*)&cch);
}
ExitOnWin32Error(er, hr, "Failed to format string");
// put the nulls back
RevealNulls(*ppwzData);
LExit:
return hr;
}
示例2: UpdateThreadCheck
extern "C" HRESULT WINAPI UpdateThreadCheck(
__in LPCWSTR wzAppId,
__in BOOL fTryExecuteUpdate
)
{
HRESULT hr = S_OK;
BOOL fLocked = FALSE;
BACKGROUND_UPDATE_THREAD_CONTEXT* pContext = NULL;
::EnterCriticalSection(&vUpdateThreadLock);
fLocked = TRUE;
if (vhUpdateThread)
{
DWORD er = ::WaitForSingleObject(vhUpdateThread, 0);
if (WAIT_OBJECT_0 == er)
{
::CloseHandle(vhUpdateThread);
vhUpdateThread = NULL;
}
else
{
hr = S_FALSE;
ExitFunction();
}
}
pContext = static_cast<BACKGROUND_UPDATE_THREAD_CONTEXT*>(MemAlloc(sizeof(BACKGROUND_UPDATE_THREAD_CONTEXT), TRUE));
ExitOnNull(pContext, hr, E_OUTOFMEMORY, "Failed to allocate memory for context.");
hr= StrAllocString(&pContext->pwzApplicationId, wzAppId, 0);
ExitOnFailure(hr, "Failed to copy app id into context.");
pContext->fExecuteUpdate = fTryExecuteUpdate;
vhUpdateThread = ::CreateThread(NULL, 0, BackgroundUpdateThread, reinterpret_cast<LPVOID>(pContext), 0, NULL);
ExitOnNullWithLastError(vhUpdateThread, hr, "Failed to create background update thread.");
pContext = NULL;
LExit:
if (pContext)
{
ReleaseStr(pContext->pwzApplicationId);
MemFree(pContext);
}
if (fLocked)
{
::LeaveCriticalSection(&vUpdateThreadLock);
}
return hr;
}
示例3: CpiGetCatalogCollection
HRESULT CpiGetCatalogCollection(
ICatalogCollection* piColl,
ICatalogObject* piObj,
LPCWSTR pwzName,
ICatalogCollection** ppiColl
)
{
HRESULT hr = S_OK;
ICOMAdminCatalog* piCatalog = NULL;
IDispatch* piDisp = NULL;
BSTR bstrName = NULL;
VARIANT vtKey;
::VariantInit(&vtKey);
// copy name string
bstrName = ::SysAllocString(pwzName);
ExitOnNull(bstrName, hr, E_OUTOFMEMORY, "Failed to allocate BSTR for collection name");
// get catalog
hr = CpiGetAdminCatalog(&piCatalog);
ExitOnFailure(hr, "Failed to get COM+ admin catalog");
// get key
hr = piObj->get_Key(&vtKey);
ExitOnFailure(hr, "Failed to get object key");
// get collecton from catalog
hr = piColl->GetCollection(bstrName, vtKey, &piDisp);
ExitOnFailure(hr, "Failed to get collection");
hr = piDisp->QueryInterface(IID_ICatalogCollection, (void**)ppiColl);
ExitOnFailure(hr, "Failed to get IID_ICatalogCollection interface");
// populate collection
hr = (*ppiColl)->Populate();
if (COMADMIN_E_OBJECTERRORS == hr)
CpiLogCatalogErrorInfo();
ExitOnFailure(hr, "Failed to populate collection");
hr = S_OK;
LExit:
// clean up
ReleaseObject(piCatalog);
ReleaseObject(piDisp);
ReleaseBSTR(bstrName);
::VariantClear(&vtKey);
return hr;
}
示例4: AddFilterToList
// private helper functions
static HRESULT AddFilterToList(SCA_FILTER** ppsfList)
{
HRESULT hr = S_OK;
SCA_FILTER* psf = (SCA_FILTER*)MemAlloc(sizeof(SCA_FILTER), TRUE);
ExitOnNull(psf, hr, E_OUTOFMEMORY, "failed to add filter to filter list");
psf->psfNext = *ppsfList;
*ppsfList = psf;
LExit:
return hr;
}
示例5: MqiInitialize
HRESULT MqiInitialize()
{
HRESULT hr = S_OK;
// load mqrt.dll
ghMQRT = ::LoadLibraryW(L"mqrt.dll");
ExitOnNull(ghMQRT, hr, E_FAIL, "Failed to load mqrt.dll");
// get MQCreateQueue function address
gpfnMQCreateQueue = (MQCreateQueueFunc)::GetProcAddress(ghMQRT, "MQCreateQueue");
ExitOnNull(gpfnMQCreateQueue, hr, HRESULT_FROM_WIN32(::GetLastError()), "Failed get address for MQCreateQueue() function");
// get MQDeleteQueue function address
gpfnMQDeleteQueue = (MQDeleteQueueFunc)::GetProcAddress(ghMQRT, "MQDeleteQueue");
ExitOnNull(gpfnMQDeleteQueue, hr, HRESULT_FROM_WIN32(::GetLastError()), "Failed get address for MQDeleteQueue() function");
// get MQPathNameToFormatName function address
gpfnMQPathNameToFormatName = (MQPathNameToFormatNameFunc)::GetProcAddress(ghMQRT, "MQPathNameToFormatName");
ExitOnNull(gpfnMQPathNameToFormatName, hr, HRESULT_FROM_WIN32(::GetLastError()), "Failed get address for MQPathNameToFormatName() function");
// get MQGetQueueSecurity function address
gpfnMQGetQueueSecurity = (MQGetQueueSecurityFunc)::GetProcAddress(ghMQRT, "MQGetQueueSecurity");
ExitOnNull(gpfnMQGetQueueSecurity, hr, HRESULT_FROM_WIN32(::GetLastError()), "Failed get address for MQGetQueueSecurity() function");
// get MQSetQueueSecurity function address
gpfnMQSetQueueSecurity = (MQSetQueueSecurityFunc)::GetProcAddress(ghMQRT, "MQSetQueueSecurity");
ExitOnNull(gpfnMQSetQueueSecurity, hr, HRESULT_FROM_WIN32(::GetLastError()), "Failed get address for MQSetQueueSecurity() function");
hr = S_OK;
LExit:
return hr;
}
示例6: AddWebErrorToList
static HRESULT AddWebErrorToList(SCA_WEB_ERROR** ppsweList)
{
HRESULT hr = S_OK;
SCA_WEB_ERROR* pswe = static_cast<SCA_WEB_ERROR*>(MemAlloc(sizeof(SCA_WEB_ERROR), TRUE));
ExitOnNull(pswe, hr, E_OUTOFMEMORY, "failed to allocate memory for new web error list element");
pswe->psweNext = *ppsweList;
*ppsweList = pswe;
LExit:
return hr;
}
示例7: NewSqlStr
static HRESULT NewSqlStr(
__out SCA_SQLSTR** ppsss
)
{
HRESULT hr = S_OK;
SCA_SQLSTR* psss = static_cast<SCA_SQLSTR*>(MemAlloc(sizeof(SCA_SQLSTR), TRUE));
ExitOnNull(psss, hr, E_OUTOFMEMORY, "failed to allocate memory for new sql string element");
*ppsss = psss;
LExit:
return hr;
}
示例8: NewDb
static HRESULT NewDb(
__out SCA_DB** ppsd
)
{
HRESULT hr = S_OK;
SCA_DB* psd = static_cast<SCA_DB*>(MemAlloc(sizeof(SCA_DB), TRUE));
ExitOnNull(psd, hr, E_OUTOFMEMORY, "failed to allocate memory for new database element");
*ppsd = psd;
LExit:
return hr;
}
示例9: AddMimeMapToList
static HRESULT AddMimeMapToList(SCA_MIMEMAP** ppsmmList)
{
HRESULT hr = S_OK;
SCA_MIMEMAP* psmm = static_cast<SCA_MIMEMAP*>(MemAlloc(sizeof(SCA_MIMEMAP), TRUE));
ExitOnNull(psmm, hr, E_OUTOFMEMORY, "failed to allocate memory for new mime map list element");
psmm->psmmNext = *ppsmmList;
*ppsmmList = psmm;
LExit:
return hr;
}
示例10: NewAppExt
static HRESULT NewAppExt(
SCA_WEB_APPLICATION_EXTENSION** ppswappext
)
{
HRESULT hr = S_OK;
SCA_WEB_APPLICATION_EXTENSION* pswappext = (SCA_WEB_APPLICATION_EXTENSION*)MemAlloc(sizeof(SCA_WEB_APPLICATION_EXTENSION), TRUE);
ExitOnNull(pswappext, hr, E_OUTOFMEMORY, "failed to allocate memory for new web app ext element");
*ppswappext = pswappext;
LExit:
return hr;
}
示例11: ParseWxlControls
static HRESULT ParseWxlControls(
__in IXMLDOMElement* pElement,
__in WIX_LOCALIZATION* pWixLoc
)
{
HRESULT hr = S_OK;
IXMLDOMNode* pixn = NULL;
IXMLDOMNodeList* pixnl = NULL;
DWORD dwIdx = 0;
hr = XmlSelectNodes(pElement, L"UI|Control", &pixnl);
ExitOnLastError(hr, "Failed to get UI child nodes of Wxl File.");
hr = pixnl->get_length(reinterpret_cast<long*>(&pWixLoc->cLocControls));
ExitOnLastError(hr, "Failed to get number of UI child nodes in Wxl File.");
if (0 < pWixLoc->cLocControls)
{
pWixLoc->rgLocControls = static_cast<LOC_CONTROL*>(MemAlloc(sizeof(LOC_CONTROL) * pWixLoc->cLocControls, TRUE));
ExitOnNull(pWixLoc->rgLocControls, hr, E_OUTOFMEMORY, "Failed to allocate memory for localized controls.");
while (S_OK == (hr = XmlNextElement(pixnl, &pixn, NULL)))
{
hr = ParseWxlControl(pixn, dwIdx, pWixLoc);
ExitOnFailure(hr, "Failed to parse localized control.");
++dwIdx;
ReleaseNullObject(pixn);
}
hr = S_OK;
ExitOnFailure(hr, "Failed to enumerate all localized controls.");
}
LExit:
if (FAILED(hr) && pWixLoc->rgLocControls)
{
for (DWORD idx = 0; idx < pWixLoc->cLocControls; ++idx)
{
ReleaseStr(pWixLoc->rgLocControls[idx].wzControl);
ReleaseStr(pWixLoc->rgLocControls[idx].wzText);
}
ReleaseMem(pWixLoc->rgLocControls);
}
ReleaseObject(pixn);
ReleaseObject(pixnl);
return hr;
}
示例12: GetUserAccountName
static HRESULT GetUserAccountName(
LPCWSTR pwzKey,
LPWSTR* ppwzAccount
)
{
HRESULT hr = S_OK;
PMSIHANDLE hView, hRecKey, hRec;
LPWSTR pwzDomain = NULL;
LPWSTR pwzName = NULL;
// create parameter record
hRecKey = ::MsiCreateRecord(1);
ExitOnNull(hRecKey, hr, E_OUTOFMEMORY, "Failed to create record");
hr = WcaSetRecordString(hRecKey, 1, pwzKey);
ExitOnFailure(hr, "Failed to set record string");
// open view
hr = WcaOpenView(vcsUserQuery, &hView);
ExitOnFailure(hr, "Failed to open view on User table");
hr = WcaExecuteView(hView, hRecKey);
ExitOnFailure(hr, "Failed to execute view on User table");
// fetch record
hr = WcaFetchSingleRecord(hView, &hRec);
if (S_FALSE == hr)
ExitOnFailure(hr = HRESULT_FROM_WIN32(ERROR_NOT_FOUND), "User not found, key: %S", pwzKey);
ExitOnFailure(hr, "Failed to fetch user record");
// get user domain
hr = WcaGetRecordFormattedString(hRec, uqDomain, &pwzDomain);
ExitOnFailure(hr, "Failed to get domain");
// get user name
hr = WcaGetRecordFormattedString(hRec, uqName, &pwzName);
ExitOnFailure(hr, "Failed to get name");
// build account name
hr = CpiBuildAccountName(pwzDomain, pwzName, ppwzAccount);
ExitOnFailure(hr, "Failed to build account name");
hr = S_OK;
LExit:
// clean up
ReleaseStr(pwzDomain);
ReleaseStr(pwzName);
return hr;
}
示例13: CpiResetObjectProperty
HRESULT CpiResetObjectProperty(
ICatalogCollection* piColl,
ICatalogObject* piObj,
LPCWSTR pwzPropName
)
{
HRESULT hr = S_OK;
BSTR bstrPropName = NULL;
long lChanges = 0;
VARIANT vtVal;
::VariantInit(&vtVal);
// allocate property name string
bstrPropName = ::SysAllocString(pwzPropName);
ExitOnNull(bstrPropName, hr, E_OUTOFMEMORY, "Failed to allocate deleteable property name string");
// get value
hr = piObj->get_Value(bstrPropName, &vtVal);
ExitOnFailure(hr, "Failed to get deleteable property value");
hr = ::VariantChangeType(&vtVal, &vtVal, 0, VT_BOOL);
ExitOnFailure(hr, "Failed to change variant type");
// if the deleteable property is set
if (VARIANT_FALSE == vtVal.boolVal)
{
// clear property
vtVal.boolVal = VARIANT_TRUE;
hr = piObj->put_Value(bstrPropName, vtVal);
ExitOnFailure(hr, "Failed to get property value");
// save changes
hr = piColl->SaveChanges(&lChanges);
if (COMADMIN_E_OBJECTERRORS == hr)
CpiLogCatalogErrorInfo();
ExitOnFailure(hr, "Failed to save changes");
}
hr = S_OK;
LExit:
// clean up
ReleaseBSTR(bstrPropName);
::VariantClear(&vtVal);
return hr;
}
示例14: CabExtractWrite
static __callback UINT FAR DIAMONDAPI CabExtractWrite(__in INT_PTR hf, __in void FAR *pv, __in UINT cb)
{
HRESULT hr = S_OK;
DWORD cbWrite = 0;
ExitOnNull(hf, hr, E_INVALIDARG, "Failed to write file during cabinet extraction - no file given to write");
if (!::WriteFile(reinterpret_cast<HANDLE>(hf), pv, cb, &cbWrite, NULL))
{
ExitWithLastError(hr, "failed to write during cabinet extraction");
}
LExit:
return FAILED(hr) ? -1 : cbWrite;
}
示例15: AddPropertyToList
static HRESULT AddPropertyToList(
SCA_PROPERTY** ppspList
)
{
HRESULT hr = S_OK;
SCA_PROPERTY* psp = static_cast<SCA_PROPERTY*>(MemAlloc(sizeof(SCA_PROPERTY), TRUE));
ExitOnNull(psp, hr, E_OUTOFMEMORY, "failed to allocate memory for new property list element");
psp->pspNext = *ppspList;
*ppspList = psp;
LExit:
return hr;
}