void cleanup() 
	{
			if ( pElemProp != NULL )
			{
				pElemProp->Release();
				pElemProp = NULL;
			}
			if ( pElemProps != NULL )
			{
				pElemProps->Release(); 
				pElemProps = NULL;
			}
			if ( pElem != NULL )
			{
				pElem->Release();
				pElem = NULL;
			}
			if ( pElemColl != NULL )
			{
				pElemColl->Release(); 
				pElemColl = NULL;
			}
			if ( pParentElem != NULL )
			{
				pParentElem->Release(); 
				pParentElem = NULL;
			}
			if ( pMgr != NULL )
			{
				pMgr->Release(); 
				pMgr = NULL;
			}

			SysFreeString( bstrConfigCommitPath );
			SysFreeString( bstrSectionName );
			SysFreeString( bstrPropertyName );

			CoUninitialize();
	}
Exemple #2
0
HRESULT
GetSharedConfigEnabled(
    BOOL * pfIsSharedConfig
)
/*++

Routine Description:
   Search the configuration for the shared configuration property.

Arguments:

    pfIsSharedConfig - true if shared configuration is enabled

Return Value:
    HRESULT

--*/
{
    HRESULT                 hr = S_OK;
    IAppHostAdminManager    *pAdminManager = NULL;

    BSTR                    bstrSectionName = NULL;
    BSTR                    bstrConfigPath = NULL;

    IAppHostElement *       pConfigRedirSection = NULL;


    bstrSectionName = SysAllocString( L"configurationRedirection" );

    if ( bstrSectionName == NULL )
    {
        hr = E_OUTOFMEMORY;
        DBGERROR_HR(hr);
        goto exit;
    }

    bstrConfigPath = SysAllocString( L"MACHINE/REDIRECTION" );
    if ( bstrConfigPath == NULL )
    {
        hr = E_OUTOFMEMORY;
        DBGERROR_HR(hr);
        goto exit;
    }

    hr = CoCreateInstance( CLSID_AppHostAdminManager,
                           NULL,
                           CLSCTX_INPROC_SERVER,
                           IID_IAppHostAdminManager,
                           (VOID **)&pAdminManager );
    if( FAILED(hr) )
    {
        DBGERROR_HR(hr);
        goto exit;
    }

    hr = pAdminManager->GetAdminSection( bstrSectionName,
                                         bstrConfigPath,
                                         &pConfigRedirSection );
    if( FAILED(hr) )
    {
        DBGERROR_HR(hr);
        goto exit;
    }

    hr = GetElementBoolProperty( pConfigRedirSection,
                                 L"enabled",
                                 pfIsSharedConfig );

    if ( FAILED( hr ) )
    {
        DBGERROR_HR(hr);
        goto exit;
    }

    pConfigRedirSection->Release();
    pConfigRedirSection = NULL;


exit:

    //
    // dump config exception to setup log file (if available)
    //

    if ( pConfigRedirSection != NULL )
    {
        pConfigRedirSection->Release();
    }

    if ( pAdminManager != NULL )
    {
        pAdminManager->Release();
    }

    if ( bstrConfigPath != NULL )
    {
        SysFreeString( bstrConfigPath );
    }

    if ( bstrSectionName != NULL )
    {
        SysFreeString( bstrSectionName );
    }

    return hr;
}