IIS 7 구성 시스템에서 메타데이터 값을 가져옵니다.
구문
HRESULT GetMetadata(
[in,
string] BSTR bstrMetadataType,
[out,
retval] VARIANT* pValue
);
매개 변수
bstrMetadataType
BSTR 요청되는 메타데이터의 이름이 들어 있는 입니다.
pValue
요청된 VARIANT 메타데이터의 값을 포함하는 에 대한 포인터입니다.
반환 값
HRESULT입니다. 가능한 값에는 다음 표에 있는 값이 포함되지만, 이에 국한되는 것은 아닙니다.
| 값 | 설명 |
|---|---|
| S_OK | 작업이 성공했음을 나타냅니다. |
| ERROR_NOT_SUPPORTED | 요청된 메타데이터가 지원되지 않음을 나타냅니다. |
예제
다음 코드 예제에서는 메서드를 availableSections 사용하여 구성 스키마에서 메타데이터를 검색합니다 IAppHostAdminManager::GetMetadata .
#pragma once
#include <stdio.h>
#include <string.h>
#include <ahadmin.h>
int main()
{
IAppHostAdminManager * pMgr = NULL;
HRESULT hr = S_OK;
BSTR bstrMetadataName = SysAllocString( L"availableSections" );
VARIANT vtAvailableSections;
// 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 instance\n" );
goto exit;
}
// Get the metadata
hr = pMgr->GetMetadata( bstrMetadataName, &vtAvailableSections );
if ( FAILED( hr ) )
{
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 the requested metadata.\n" );
}
goto exit;
}
// Metadata returns in a comma-delimited string.
// Split the data and return the sections one line at a time.
wchar_t* wcMetadata = static_cast<wchar_t*>(vtAvailableSections.bstrVal);
wchar_t delim[] = L",";
wchar_t* tokenIn = NULL;
wchar_t* tokenOut = NULL;
tokenIn = wcstok_s( wcMetadata, delim, &tokenOut );
while ( tokenIn != NULL )
{
wprintf_s( L"\t%s\n", tokenIn );
tokenIn = wcstok_s( NULL, delim, &tokenOut);
}
exit:
// Exiting / Unwinding
if ( pMgr != NULL )
{
pMgr->Release();
pMgr = NULL;
}
SysFreeString( bstrMetadataName );
// 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 |