다음을 통해 공유


IAppHostPropertyCollection 인터페이스

속성의 컬렉션을 나타냅니다.

구문

interface IAppHostPropertyCollection : IUnknown  

메서드

이 인터페이스에는 메서드가 없습니다.

속성

다음 표에서는 인터페이스에 의해 노출되는 속성을 나열합니다 IAppHostPropertyCollection .

속성 Description
Count 컬렉션의 숫자 속성을 가져옵니다.
Item 컬렉션에서 요청된 인덱스 또는 속성 이름을 가진 속성을 가져옵니다.

예제

다음 코드 예제를 사용 하는 방법을 보여 줍니다.는 IAppHostPropertyCollection 구성 섹션의 defaultDocument 속성에 enabled 액세스 하는 인터페이스입니다.


#pragma once

#include <stdio.h>
#include <string.h>
#include <ahadmin.h>

int main()
{
    IAppHostAdminManager        * pMgr        = NULL;
    IAppHostElement             * pParentElem = NULL;
    IAppHostPropertyCollection  * pElemProps  = NULL;
    IAppHostProperty            * pElemProp   = NULL;

    HRESULT hr                    = S_OK;
    BSTR    bstrConfigCommitPath  = SysAllocString( L"MACHINE/WEBROOT/APPHOST" );
    BSTR    bstrSectionName       = SysAllocString( L"system.webServer/defaultDocument" );
    BSTR    bstrPropertyName      = SysAllocString( L"enabled" );
    VARIANT vtValue;
    VARIANT vtPropertyName;
    vtPropertyName.vt             = VT_BSTR;
    vtPropertyName.bstrVal        = bstrPropertyName;

    // Initialize
    hr = CoInitializeEx( NULL, COINIT_MULTITHREADED );
    if ( FAILED( hr ) )
    {
        printf_s( "ERROR: Unable to initialize\n" );
        goto exit;
    } 

    // Create
    hr = CoCreateInstance( __uuidof( AppHostAdminManager ), NULL, 
            CLSCTX_INPROC_SERVER,
            __uuidof( IAppHostAdminManager ), (void**) &pMgr );
    if( FAILED( hr ) )
    {
        printf_s( "ERROR: Unable to create an IAppHostAdminManager\n" );
        goto exit;
    }
    
    // Get the admin section
    hr = pMgr->GetAdminSection( bstrSectionName, bstrConfigCommitPath, &pParentElem );
    if ( FAILED( hr ) || ( &pParentElem == NULL ) )
    {
        if ( E_ACCESSDENIED == hr )
        {
            printf_s( "ERROR: Access to configuration denied.\n" );
            printf_s( "       Run sample as an administrator.\n" );
        }
        else
        {
            printf_s( "ERROR: Unable to get configuration section.\n" );
        }
        goto exit;
    }

    // Get the child elements
    hr = pParentElem->get_Properties( &pElemProps );
    if ( FAILED( hr ) || ( &pElemProps == NULL ) )
    {
        wprintf_s( L"ERROR: Unable to access attributes %s\n", bstrSectionName );
        goto exit;
    }

    // Get the requested property
    hr = pElemProps->get_Item( vtPropertyName, &pElemProp );
    if ( FAILED( hr ) || ( pElemProp == NULL ) )
    {
        wprintf_s( L"ERROR: Unable to access attribute: %s\n", bstrPropertyName );
        goto exit;
    }

    // Get the property value
    hr = pElemProp->get_Value( &vtValue );
    if ( FAILED( hr ) )
    {    
        wprintf_s( L"ERROR: Unable to access attribute value: %s\n", bstrPropertyName );
        goto exit;
    }

    wprintf_s( L"defaultDocument is %sabled\n", 
        ( ( vtValue.boolVal == VARIANT_TRUE) ? L"en" : L"dis" ) ) ;
exit:
    // Exiting / Unwinding
    if ( pElemProp != NULL )
    {
        pElemProp->Release();
        pElemProp = NULL;
    }
    if ( pElemProps != NULL )
    {
        pElemProps->Release(); 
        pElemProps = NULL;
    }
    if ( pParentElem != NULL )
    {
        pParentElem->Release(); 
        pParentElem = NULL;
    }
    if ( pMgr != NULL )
    {
        pMgr->Release(); 
        pMgr = NULL;
    }

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

    // Uninitialize
    CoUninitialize();

    return 0;
};

상속 계층 구조

IUnknown

IAppHostPropertyCollection

요구 사항

형식 Description
클라이언트 - Windows Vista의 IIS 7.0
- Windows 7의 IIS 7.5
- Windows 8의 IIS 8.0
- WINDOWS 10 IIS 10.0
서버 - Windows Server 2008의 IIS 7.0
- Windows Server 2008 R2의 IIS 7.5
- Windows Server 2012의 IIS 8.0
- Windows Server 2012 R2의 IIS 8.5
- WINDOWS SERVER 2016 IIS 10.0
제품 - IIS 7.0, IIS 7.5, IIS 8.0, IIS 8.5, IIS 10.0
- IIS Express 7.5, IIS Express 8.0, IIS Express 10.0
헤더 Ahadmin.h

참고 항목

애플리케이션 호스트 관리 인터페이스
IAppHostProperty 인터페이스