다음을 통해 공유


IAppHostWritableAdminManager::CommitPath 속성

변경 내용을 커밋해야 하는 구성 경로를 가져오거나 설정합니다.

구문

HRESULT get_CommitPath(  
   [out,  
   retval,  
   string] BSTR* pbstrCommitPath  
);  
HRESULT put_CommitPath(  
   BSTR bstrCommitPath  
);  

매개 변수

pbstrCommitPath
변경 내용을 커밋해야 하는 구성 경로가 포함된 에 대한 포인터 BSTR 입니다.

bstrCommitPath
BSTR 새 커밋 경로가 포함된 입니다.

반환 값

HRESULT입니다. 가능한 값에는 다음 표에 있는 값이 포함되지만, 이에 국한되는 것은 아닙니다.

설명
S_OK 작업이 성공했음을 나타냅니다.

예제

다음 코드 예제에서는 속성을 설정하고 CommitPath IIS 7 구성을 변경한 다음 IAppHostWritableAdminManager::CommitChanges 메서드를 사용하여 이러한 변경 내용을 IIS 7 구성 시스템에 커밋하는 방법을 보여 줍니다.


#pragma once

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

int main()
{
    IAppHostWritableAdminManager *    pWMgr       = NULL;
    IAppHostElement              *    pElement    = NULL;
    
    HRESULT  hr                   = S_OK;
    BSTR     bstrConfigCommitPath = SysAllocString(L"MACHINE/WEBROOT/APPHOST");
    BSTR     bstrSectionName      = SysAllocString(L"system.applicationHost/sites");
    BSTR     bstrConfigSource     = SysAllocString(L"sites.config");
    BSTR     bstrConfigSourceAttr = SysAllocString(L"configSource");
    VARIANT  vtConfigSource;
    vtConfigSource.vt             = VT_BSTR;
    vtConfigSource.bstrVal        = bstrConfigSource;

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

    // Create
    hr = CoCreateInstance( __uuidof( AppHostWritableAdminManager ), NULL, 
            CLSCTX_INPROC_SERVER,
            __uuidof( IAppHostWritableAdminManager ), (void**) &pWMgr );
    if( FAILED( hr ) )
    {
        printf_s( "ERROR: Unable to create an IAppHostWritableAdminManager instance\n" );
        goto exit;
    }

    // Set the commit path
    hr = pWMgr->put_CommitPath( bstrConfigCommitPath );
    if ( FAILED( hr ) )
    {
        printf_s( "ERROR: Unable to set the configuration path" );
        goto exit;
    }

    // Get the admin section
    hr = pWMgr->GetAdminSection( bstrSectionName, bstrConfigCommitPath, &pElement );
    if ( FAILED( hr ) || ( &pElement == 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 asp configuration section.\n" );
        }
        goto exit;
    }
        
    // Set the metadata
    hr = pElement->SetMetadata( bstrConfigSourceAttr, vtConfigSource );
    if ( FAILED( hr ) )
    {
        printf_s( "ERROR: Unable to set metadata\n" );
        goto exit;
    }

    pWMgr->CommitChanges();
exit:
    // Exiting / Unwinding
    if ( pElement != NULL )
    {
        pElement -> Release ();
        pElement = NULL;
    }

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

    SysFreeString( bstrConfigCommitPath );
    SysFreeString( bstrSectionName );
    SysFreeString( bstrConfigSource );
    SysFreeString( bstrConfigSourceAttr );


    // Uninitialize
    CoUninitialize();

    return 0;
};

요구 사항

형식 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

참고 항목

IAppHostWritableAdminManager 인터페이스