현재 IAppHostElement 인터페이스 아래에 중첩된 자식 요소의 컬렉션을 나타냅니다.
구문
HRESULT get_ChildElements(
[out,
retval] IAppHostChildElementCollection** ppElements
);
매개 변수
ppElements
IAppHostChildElementCollection 인터페이스에 대한 포인터에 대한 포인터입니다.
반환 값
HRESULT입니다. 가능한 값에는 다음 표에 있는 값이 포함되지만, 이에 국한되는 것은 아닙니다.
| 값 | 설명 |
|---|---|
| S_OK | 작업이 성공했음을 나타냅니다. |
설명
속성에 IAppHostElement::ChildElements 표시되는 자식 요소 컬렉션은 IAppHostElement::Collection 속성에 표시되는 중첩된 요소 컬렉션과 다릅니다. 두 컬렉션 모두 인터페이스에 대한 포인터를 IAppHostElement 포함합니다. 그러나 구성 섹션과 같은 system.webServer/asp 고유한 자식 요소에 대한 구성을 쿼리할 때 속성을 사용해야 IAppHostElement::ChildElements 합니다. 다음 구성 예제 <cache/> 에서 요소는 구성 섹션의 system.webServer/asp 자식 요소입니다.
<system.webServer>
<asp>
<cache diskTemplateCacheDirectory="%SystemDrive%\inetpub\temp\ASP Compiled Templates" />
</asp>
</system.webServer>
구성 섹션과 같은 system.webServer/sites 고유 키 또는 다중 특성 키가 포함된 자식 요소에 대한 구성을 쿼리할 때 속성을 사용해야 IAppHostElement::Collection 합니다. 다음 구성 예제 <site/> 에서 요소는 컬렉션 요소이며 <applicationDefaults/> 요소는 구성 섹션의 system.applicationHost/sites 자식 요소입니다.
<system.applicationHost>
<sites>
<site name="Default Web Site" id="1">
<application path="/">
<virtualDirectory path="/"
physicalPath="%SystemDrive%\inetpub\wwwroot" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80:" />
</bindings>
</site>
<site name="Microsoft.com" id="35">
<bindings>
<binding protocol="http"
bindingInformation="*:80:microsoft.com" />
</bindings>
</site>
<siteDefaults>
<logFile customLogPluginClsid="{FF160663-DE82-11CF-BC0A-00AA006111E0}"
directory="%SystemDrive%\inetpub\logs\LogFiles" />
<traceFailedRequestsLogging
directory="%SystemDrive%\inetpub\logs\FailedReqLogFiles" />
</siteDefaults>
<applicationDefaults applicationPool="DefaultAppPool" />
<virtualDirectoryDefaults allowSubDirConfig="true" />
</sites>
</system.applicationHost>
예제
다음 코드 예제에서는 MACHINE/WEBROOT/APPHOST 구성 경로에 대한 구성 섹션의 system.webServer/asp 모든 자식 요소를 표시합니다.
#pragma once
#include <stdio.h>
#include <string.h>
#include <ahadmin.h>
int main()
{
IAppHostAdminManager * pMgr = NULL;
IAppHostElement * pParentElem = NULL;
IAppHostChildElementCollection * pChildElems = NULL;
IAppHostElement * pChildElem = NULL;
HRESULT hr = S_OK;
BSTR bstrSectionName = SysAllocString( L"system.webServer/asp" );
BSTR bstrChildElemName = NULL;
DWORD dwElementCount = 0;
// Initialize
hr = CoInitializeEx( NULL, COINIT_MULTITHREADED );
if ( FAILED( hr ) )
{
printf_s( "ERROR: Unable to initialize\n" );
goto exit;
}
// Create an admin manager
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
wprintf_s( L"Getting %s\n", bstrSectionName );
hr = pMgr->GetAdminSection( bstrSectionName, NULL, &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 asp configuration section.\n" );
}
goto exit;
}
// Get the child elements
wprintf_s( L"Getting child elements\n" );
hr = pParentElem->get_ChildElements( &pChildElems );
if ( FAILED( hr ) || ( &pChildElems == NULL ) )
{
wprintf_s( L"ERROR: Unable to access child elements of %s\n", bstrSectionName );
goto exit;
}
// Loop through child elements
wprintf_s( L"Seaching for child elements of %s\n", bstrSectionName );
hr = pChildElems->get_Count( &dwElementCount );
for( USHORT i = 0; i < dwElementCount; i++ )
{
VARIANT vtItemIndex;
vtItemIndex.vt = VT_I2;
vtItemIndex.iVal = i;
// Get the section group
hr = pChildElems->get_Item( vtItemIndex, &pChildElem );
if ( FAILED( hr ) || ( &pChildElem == NULL ) )
{
wprintf_s( L"ERROR: Unable to find child element: %d\n", i );
goto loop_cleanup;
}
// Get the name
hr = pChildElem->get_Name ( &bstrChildElemName );
if ( FAILED( hr ) )
{
wprintf_s( L"ERROR: Unable to get child element name.\n" );
goto loop_cleanup;
}
wprintf_s( L"\tChild element found: %s\n", bstrChildElemName );
loop_cleanup:
if ( pChildElem != NULL )
{
pChildElem->Release();
pChildElem = NULL;
}
SysFreeString( bstrChildElemName );
}
exit:
// Exiting / Unwinding
if ( pChildElems != NULL )
{
pChildElems->Release();
pChildElems = NULL;
}
if ( pParentElem != NULL )
{
pParentElem->Release();
pParentElem = NULL;
}
if ( pMgr != NULL )
{
pMgr->Release();
pMgr = NULL;
}
SysFreeString( bstrChildElemName );
SysFreeString( bstrSectionName );
// 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 |