当前位置: 首页>>代码示例>>C++>>正文


C++ AssertSz函数代码示例

本文整理汇总了C++中AssertSz函数的典型用法代码示例。如果您正苦于以下问题:C++ AssertSz函数的具体用法?C++ AssertSz怎么用?C++ AssertSz使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了AssertSz函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: WcaInitializeWow64

/********************************************************************
 WcaInitializeWow64() - Initializes the Wow64 API

********************************************************************/
extern "C" HRESULT WIXAPI WcaInitializeWow64()
{
    AssertSz(WcaIsInitialized(), "WcaInitialize() should be called before calling WcaInitializeWow64()");
    AssertSz(!WcaIsWow64Initialized(), "WcaInitializeWow64() should not be called twice without calling WcaFinalizeWow64()");

    s_fWow64Initialized = FALSE;
    HRESULT hr = S_OK;
    s_Wow64FSRevertState = NULL;
    s_fWow64FSDisabled = false;

    // Test if we have access to the Wow64 API, and store the result in bWow64APIPresent
    s_hKernel32 = ::GetModuleHandleW(L"kernel32.dll");
    if (!s_hKernel32)
    {
        ExitWithLastError(hr, "failed to get handle to kernel32.dll");
    }

    // This will test if we have access to the Wow64 API
    s_pfnIsWow64Process = (BOOL (*)(HANDLE, PBOOL))::GetProcAddress(s_hKernel32, "IsWow64Process");
    if (NULL != s_pfnIsWow64Process)
    {
        s_pfnDisableWow64 = (BOOL (*)(PVOID *))::GetProcAddress(s_hKernel32, "Wow64DisableWow64FsRedirection");
        // If we fail, log the error but proceed, because we may not need a particular function, or the Wow64 API at all
        if (!s_pfnDisableWow64)
        {
            return S_FALSE;
        }

        s_pfnRevertWow64 = (BOOL (*)(PVOID))::GetProcAddress(s_hKernel32, "Wow64RevertWow64FsRedirection");
        if (!s_pfnRevertWow64)
        {
            return S_FALSE;
        }

        if (s_pfnDisableWow64 && s_pfnRevertWow64)
        {
            s_fWow64Initialized = TRUE;
        }
    }
    else
    {
        return S_FALSE;
    }

LExit:

    return hr;
}
开发者ID:BMurri,项目名称:wix3,代码行数:52,代码来源:wcawow64.cpp

示例2: FARINTERNAL_

FARINTERNAL_(void) UtRemoveExtraOlePresStreams(LPSTORAGE pstg, int iStart)
{
	VDATEHEAP();

	HRESULT hr; // error code from stream deletion
	OLECHAR szName[sizeof(OLE_PRESENTATION_STREAM)/sizeof(OLECHAR)];
		// space for the stream names

	// if the stream number is invalid, do nothing
	if ((iStart < 0)  || (iStart >= OLE_MAX_PRES_STREAMS))
		return;
	
	// create presentation stream name
	_xstrcpy(szName, OLE_PRESENTATION_STREAM);
	UtGetPresStreamName(szName, iStart);
	
	// for each of these streams that exists, get rid of it
	while((hr = pstg->DestroyElement(szName)) == NOERROR)
	{
		// if we've gotten to the end of the possible streams, quit
		if (++iStart >= OLE_MAX_PRES_STREAMS)
			break;
		
		// Get the next presentation stream name
		UtGetPresStreamName(szName, iStart);
	}       

	// since the only reason these streams should be open, the first
	// failure had better be that the file was not found, and not
	// anything else (such as STG_E_ACCESSDENIED)
	AssertSz(hr == STG_E_FILENOTFOUND,
			"UtRemoveExtraOlePresStreams failure");
}
开发者ID:mingpen,项目名称:OpenNT,代码行数:33,代码来源:ole2util.cpp

示例3: WcaFetchSingleRecord

/********************************************************************
WcaFetchSingleRecord() - gets a single record from a view on the installing database

********************************************************************/
extern "C" HRESULT WIXAPI WcaFetchSingleRecord(
    __in MSIHANDLE hView,
    __out MSIHANDLE* phRec
    )
{
    if (!hView|| !phRec)
    {
        return E_INVALIDARG;
    }

    HRESULT hr = S_OK;
    UINT er = ::MsiViewFetch(hView, phRec);
    if (ERROR_NO_MORE_ITEMS == er)
    {
        hr = S_FALSE;
    }
    else
    {
        hr = HRESULT_FROM_WIN32(er);
    }
    ExitOnFailure(hr, "failed to fetch single record from view");

#ifdef DEBUG // only do this in debug to verify that a single record was returned
    MSIHANDLE hRecTest;
    er = ::MsiViewFetch(hView, &hRecTest);
    AssertSz(ERROR_NO_MORE_ITEMS == er && NULL == hRecTest, "WcaSingleFetch() did not fetch a single record");
    ::MsiCloseHandle(hRecTest);
#endif

LExit:
    return hr;
}
开发者ID:lukaswinzenried,项目名称:WixCustBa,代码行数:36,代码来源:wcawrap.cpp

示例4: ended

/********************************************************************
RmuEndSession - Ends the session.

If the session was joined by RmuJoinSession, any remaining resources
are registered before the session is ended (left).

********************************************************************/
extern "C" HRESULT DAPI RmuEndSession(
    __in PRMU_SESSION pSession
    )
{
    HRESULT hr = S_OK;
    DWORD er = ERROR_SUCCESS;

    AssertSz(vcRmuInitialized, "Restart Manager was not properly initialized.");

    // Make sure all resources are registered if we joined the session.
    if (!pSession->fStartedSessionHandle)
    {
        hr = RmuRegisterResources(pSession);
        ExitOnFailure(hr, "Failed to register remaining resources.");
    }

    er = vpfnRmEndSession(pSession->dwSessionHandle);
    ExitOnWin32Error(er, hr, "Failed to end the Restart Manager session.");

LExit:
    if (pSession->fInitialized)
    {
        ::DeleteCriticalSection(&pSession->cs);
    }

    ReleaseNullStrArray(pSession->rgsczFilenames, pSession->cFilenames);
    ReleaseNullApplicationArray(pSession->rgApplications, pSession->cApplications);
    ReleaseNullStrArray(pSession->rgsczServiceNames, pSession->cServiceNames);
    ReleaseNullMem(pSession);

    RmuUninitialize();

    return hr;
}
开发者ID:BMurri,项目名称:wix3,代码行数:41,代码来源:rmutil.cpp

示例5: AssertSz

//+---------------------------------------------------------------------------
//
//  Member:     CDispRoot::SetDestination
//
//  Synopsis:   Set destination rendering surface.
//
//  Arguments:  hdc         DC destination
//              pSurface    IDirectDrawSurface
//              fOnscreen   TRUE if rendering surface is onscreen
//
//  Notes:
//
//----------------------------------------------------------------------------
void CDispRoot::SetDestination(HDC hdc, IDirectDrawSurface* pDDSurface)
{
    AssertSz(!_fDrawLock, "Illegal call to SetDestination inside Draw()");
    
    CDispSurface* pSurface = NULL;

    if(hdc)
	{
		pSurface = new CDispSurface(hdc);
	}
    else if(pDDSurface)
	{
		pSurface = new CDispSurface(pDDSurface);
	}

    if(pSurface)
    {
        if(_pRenderSurface)
		{
			delete _pRenderSurface;
		}

        _pRenderSurface = pSurface;
        _drawContext.SetDispSurface(_pRenderSurface);
    }
}
开发者ID:hufuman,项目名称:xindows,代码行数:39,代码来源:DispRoot.cpp

示例6: DependencyExecutePackageProviderAction

extern "C" HRESULT DependencyExecutePackageProviderAction(
    __in const BURN_EXECUTE_ACTION* pAction
    )
{
    AssertSz(BURN_EXECUTE_ACTION_TYPE_PACKAGE_PROVIDER == pAction->type, "Execute action type not supported by this function.");

    HRESULT hr = S_OK;
    const BURN_PACKAGE* pPackage = pAction->packageProvider.pPackage;

    // Register or unregister the package provider(s).
    if (BURN_DEPENDENCY_ACTION_REGISTER == pAction->packageProvider.action)
    {
        hr = RegisterPackageProvider(pPackage);
        ExitOnFailure(hr, "Failed to register the package providers.");
    }
    else if (BURN_DEPENDENCY_ACTION_UNREGISTER == pAction->packageProvider.action)
    {
        UnregisterPackageProvider(pPackage);
    }

LExit:
    if (!pPackage->fVital)
    {
        hr = S_OK;
    }

    return hr;
}
开发者ID:Alyoshak,项目名称:wix3,代码行数:28,代码来源:dependency.cpp

示例7: RmuRegisterResources

/********************************************************************
RmuRegisterResources - Registers resources for the Restart Manager.

This should be called rarely because it is expensive to run. Call
functions like RmuAddFile for multiple resources then commit them
as a batch of updates to RmuRegisterResources.

Duplicate resources appear to be handled by Restart Manager.
Only one WM_QUERYENDSESSION is being sent for each top-level window.

********************************************************************/
extern "C" HRESULT DAPI RmuRegisterResources(
    __in PRMU_SESSION pSession
    )
{
    HRESULT hr = S_OK;
    DWORD er = ERROR_SUCCESS;
    HMODULE hModule = NULL;
    PFNRMREGISTERRESOURCES pfnRmRegisterResources = NULL;

    AssertSz(vcRmuInitialized, "Restart Manager was not properly initialized.");

    ::EnterCriticalSection(&pSession->cs);

    er = vpfnRmRegisterResources(
        pSession->dwSessionHandle,
        pSession->cFilenames,
        pSession->rgsczFilenames,
        pSession->cApplications,
        pSession->rgApplications,
        pSession->cServiceNames,
        pSession->rgsczServiceNames
        );
    ExitOnWin32Error(er, hr, "Failed to register the resources with the Restart Manager session.");

    // Empty the arrays if registered in case additional resources are added later.
    ReleaseNullStrArray(pSession->rgsczFilenames, pSession->cFilenames);
    ReleaseNullApplicationArray(pSession->rgApplications, pSession->cApplications);
    ReleaseNullStrArray(pSession->rgsczServiceNames, pSession->cServiceNames);

LExit:
    ::LeaveCriticalSection(&pSession->cs);
    return hr;
}
开发者ID:AnalogJ,项目名称:Wix3.6Toolset,代码行数:44,代码来源:rmutil.cpp

示例8: TRACEBEGIN

/*
 *	CRchTxtPtr::InitRunPtrs(cp)
 *
 *	@mfunc
 *		Initialize Run Ptrs of this rich-text ptr to correspond to
 *		document given by ped and to cp given by cp.
 */
void CRchTxtPtr::InitRunPtrs(
	LONG cp)			// @parm character position to move RunPtrs to
{
	TRACEBEGIN(TRCSUBSYSBACK, TRCSCOPEINTERN, "CRchTxtPtr::InitRunPtrs");

	CTxtStory *pStory;

	AssertSz(GetPed(), "RTP::InitRunPtrs: illegal GetPed()");

	if( IsRich() || IsIMERich() )						
	{
		pStory = GetPed()->GetTxtStory();
		if(pStory->_pCFRuns)						//  and there's RichData,
		{											//  initialize format-run ptrs
			_rpCF.SetRunArray((CRunArray *)pStory->_pCFRuns);
			_rpCF.BindToCp(cp);
		}
		if (pStory->_pPFRuns)
		{
			_rpPF.SetRunArray((CRunArray *)pStory->_pPFRuns);
			_rpPF.BindToCp(cp);
		}
	}
 
}
开发者ID:achellies,项目名称:DUI_LIb,代码行数:32,代码来源:rtext.cpp

示例9: DependencyExecutePackageDependencyAction

extern "C" HRESULT DependencyExecutePackageDependencyAction(
    __in BOOL fPerMachine,
    __in const BURN_EXECUTE_ACTION* pAction
    )
{
    AssertSz(BURN_EXECUTE_ACTION_TYPE_PACKAGE_DEPENDENCY == pAction->type, "Execute action type not supported by this function.");

    HRESULT hr = S_OK;
    const BURN_PACKAGE* pPackage = pAction->packageDependency.pPackage;

    // Register or unregister the bundle as a dependent of each package dependency provider.
    if (BURN_DEPENDENCY_ACTION_REGISTER == pAction->packageDependency.action)
    {
        hr = RegisterPackageDependency(fPerMachine, pPackage, pAction->packageDependency.sczBundleProviderKey);
        ExitOnFailure(hr, "Failed to register the dependency on the package provider.");
    }
    else if (BURN_DEPENDENCY_ACTION_UNREGISTER == pAction->packageDependency.action)
    {
        UnregisterPackageDependency(fPerMachine, pPackage, pAction->packageDependency.sczBundleProviderKey);
    }

LExit:
    if (!pPackage->fVital)
    {
        hr = S_OK;
    }

    return hr;
}
开发者ID:Alyoshak,项目名称:wix3,代码行数:29,代码来源:dependency.cpp

示例10: PipeTerminateChildProcess

/*******************************************************************
 PipeTerminateChildProcess - 

*******************************************************************/
extern "C" HRESULT PipeTerminateChildProcess(
    __in BURN_PIPE_CONNECTION* pConnection,
    __in DWORD dwParentExitCode,
    __in BOOL fRestart
    )
{
    HRESULT hr = S_OK;
    BYTE* pbData = NULL;
    SIZE_T cbData = 0;

    // Prepare the exit message.
    hr = BuffWriteNumber(&pbData, &cbData, dwParentExitCode);
    ExitOnFailure(hr, "Failed to write exit code to message buffer.");

    hr = BuffWriteNumber(&pbData, &cbData, fRestart);
    ExitOnFailure(hr, "Failed to write restart to message buffer.");

    // Send the messages.
    if (INVALID_HANDLE_VALUE != pConnection->hCachePipe)
    {
        hr = WritePipeMessage(pConnection->hCachePipe, static_cast<DWORD>(BURN_PIPE_MESSAGE_TYPE_TERMINATE), pbData, cbData);
        ExitOnFailure(hr, "Failed to post terminate message to child process cache thread.");
    }

    hr = WritePipeMessage(pConnection->hPipe, static_cast<DWORD>(BURN_PIPE_MESSAGE_TYPE_TERMINATE), pbData, cbData);
    ExitOnFailure(hr, "Failed to post terminate message to child process.");

    // If we were able to get a handle to the other process, wait for it to exit.
    if (pConnection->hProcess)
    {
        if (WAIT_FAILED == ::WaitForSingleObject(pConnection->hProcess, PIPE_WAIT_FOR_CONNECTION * PIPE_RETRY_FOR_CONNECTION))
        {
            ExitWithLastError(hr, "Failed to wait for child process exit.");
        }

#ifdef DEBUG
        DWORD dwChildExitCode = 0;
        DWORD dwErrorCode = ERROR_SUCCESS;
        BOOL fReturnedExitCode = ::GetExitCodeProcess(pConnection->hProcess, &dwChildExitCode);
        if (!fReturnedExitCode)
        {
            dwErrorCode = ::GetLastError(); // if the other process is elevated and we are not, then we'll get ERROR_ACCESS_DENIED.

            // The unit test use a thread instead of a process so try to get the exit code from
            // the thread because we failed to get it from the process.
            if (ERROR_INVALID_HANDLE == dwErrorCode)
            {
                fReturnedExitCode = ::GetExitCodeThread(pConnection->hProcess, &dwChildExitCode);
            }
        }
        AssertSz((fReturnedExitCode && dwChildExitCode == dwParentExitCode) ||
                 (!fReturnedExitCode && ERROR_ACCESS_DENIED == dwErrorCode),
                 "Child elevated process did not return matching exit code to parent process.");
#endif
    }

LExit:
    return hr;
}
开发者ID:firegiant,项目名称:wix3,代码行数:63,代码来源:pipe.cpp

示例11: AssertSz

void CAdorner::HandleViewChange(
	  DWORD		    flags,
	  const RECT*	prcClient,	// global coordinates
	  const RECT*	prcClip,	// global coordinates
	  CDispNode*	pDispNode)
{
	AssertSz(0, "Unexpected/Unimplemented method called in CAdorner");
}
开发者ID:hufuman,项目名称:xindows,代码行数:8,代码来源:Adorner.cpp

示例12: Dutil_Trace

/*******************************************************************
Dutil_Trace

*******************************************************************/
extern "C" void DAPI Dutil_Trace(
								 __in LPCSTR szFile,
								 __in int iLine,
								 __in REPORT_LEVEL rl,
								 __in LPCSTR szFormat,
								 ...
								 )
{
	AssertSz(REPORT_NONE != rl, "REPORT_NONE is not a valid tracing level");

	HRESULT hr = S_OK;
	char szOutput[DUTIL_STRING_BUFFER];
	char szMsg[DUTIL_STRING_BUFFER];

	if (Dutil_rlCurrentTrace < rl)
		return;

	va_list args;
	va_start(args, szFormat);
	hr = StringCchVPrintfA(szOutput, countof(szOutput), szFormat, args);
	va_end(args);

	if (SUCCEEDED(hr))
	{
		LPCSTR szPrefix = "Trace/u";
		char szMsg[DUTIL_STRING_BUFFER];
		switch (rl)
		{
		case REPORT_STANDARD:
			szPrefix = "Trace/s";
			break;
		case REPORT_VERBOSE:
			szPrefix = "Trace/v";
			break;
		case REPORT_DEBUG:
			szPrefix = "Trace/d";
			break;
		}

		if (Dutil_fTraceFilenames)
			hr = StringCchPrintfA(szMsg, countof(szMsg), "%s [%s,%d]: %s\r\n", szPrefix, szFile, iLine, szOutput);
		else
			hr = StringCchPrintfA(szMsg, countof(szMsg), "%s: %s\r\n", szPrefix, szOutput);

		if (SUCCEEDED(hr))
			OutputDebugStringA(szMsg);
		// else fall through to the case below
	}

	if (FAILED(hr))
	{
		if (Dutil_fTraceFilenames)
			StringCchPrintfA(szMsg, countof(szMsg), "Trace [%s,%d]: message too long, skipping\r\n", szFile, iLine);
		else
			StringCchPrintfA(szMsg, countof(szMsg), "Trace: message too long, skipping\r\n");
		OutputDebugStringA(szMsg);
	}
}
开发者ID:codeboost,项目名称:libertv,代码行数:62,代码来源:dutil.cpp

示例13: MemAlloc

extern "C" LPVOID DAPI MemAlloc(
    __in SIZE_T cbSize,
    __in BOOL fZero
    )
{
//    AssertSz(vfMemInitialized, "MemInitialize() not called, this would normally crash");
    AssertSz(cbSize > 0, "MemAlloc() called with invalid size");
    return ::HeapAlloc(::GetProcessHeap(), fZero ? HEAP_ZERO_MEMORY : 0, cbSize);
}
开发者ID:lukaswinzenried,项目名称:WixCustBa,代码行数:9,代码来源:memutil.cpp

示例14: AssertSz

/*
*  CArrayBase::ArInsert
*
*  @mfunc Inserts <p celIns> new elements at index <p iel>
*
*  @rdesc A pointer to the newly inserted elements.  Will be NULL on
*  failure.
*/
void* CArrayBase::ArInsert(
       DWORD iel,       //@parm the index at which to insert
       DWORD celIns)    //@parm the number of elements to insert
{
    char*   pel;
    DWORD   celNew;
    HRESULT hr;

    AssertSz(iel<=_cel, "CArrayBase::Insert() - Insert out of range");

    if(iel >= _cel)
    {
        return ArAdd(celIns, NULL);
    }

    if(_cel+celIns > _celMax) // need to grow
    {
        AssertSz(_prgel, "CArrayBase::Insert() - Growing a non existent array !");

        celNew = max(DWORD(celGrow), celIns+celGrow-celIns%celGrow);
        pel = _prgel;
        hr = MemRealloc((void**)&pel, (_celMax+celNew)*_cbElem);
        if(hr)
        {
            AssertSz(FALSE, "CArrayBase::Insert() - Couldn't realloc line array");
            return NULL;
        }
        MemSetName((pel, "CArrayBase data - %d elements", celNew));

        _prgel = pel;
        _celMax += celNew;
    }
    pel = _prgel + iel*_cbElem;
    if(iel < _cel) // Nove Elems up to make room for new ones
    {
        memmove(pel+celIns*_cbElem, pel, (_cel-iel)*_cbElem);
        ZeroMemory(pel, celIns*_cbElem);
    }

    _cel += celIns;
    return pel;
}
开发者ID:hufuman,项目名称:xindows,代码行数:50,代码来源:Array2.cpp

示例15: AssertSz

CLine& CLinePtr::operator[](long dRun)
{
    if(_prgRun)
    {
        return *CRunPtr<CLine>::GetRunRel(dRun);
    }

    AssertSz(dRun+GetIRun()==0 , "LP::[]: inconsistent line ptr");

    return  *(CLine*)CRunPtr<CLine>::GetRunAbs(GetIRun());
}
开发者ID:hufuman,项目名称:xindows,代码行数:11,代码来源:line.cpp


注:本文中的AssertSz函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。