IAppHostAdminManager::GetMetadata (Método)
Obtiene los valores de metadatos del sistema de configuración de IIS 7.
Sintaxis
HRESULT GetMetadata(
[in,
string] BSTR bstrMetadataType,
[out,
retval] VARIANT* pValue
);
Parámetros
bstrMetadataType
que BSTR
contiene el nombre de los metadatos que se solicitan.
pValue
Puntero a un VARIANT
objeto que contiene el valor de los metadatos solicitados.
Valor devuelto
Una clase HRESULT
. Entre los valores posibles se incluyen los que se indican en la tabla siguiente, entre otros.
Valor | Descripción |
---|---|
S_OK | Indica que la operación se realizó correctamente. |
ERROR_NOT_SUPPORTED | Indica que no se admiten los metadatos solicitados. |
Ejemplo
En el ejemplo de código siguiente se recuperan los availableSections
metadatos del esquema de configuración mediante el IAppHostAdminManager::GetMetadata
método .
#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;
};
Requisitos
Tipo | Descripción |
---|---|
Remoto | - IIS 7.0 en Windows Vista - IIS 7.5 en Windows 7 - IIS 8.0 en Windows 8 - IIS 10.0 en Windows 10 |
Servidor | - IIS 7.0 en Windows Server 2008 - IIS 7.5 en Windows Server 2008 R2 - IIS 8.0 en Windows Server 2012 - IIS 8.5 en Windows Server 2012 R2 - IIS 10.0 en Windows Server 2016 |
Producto | - 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 |
Encabezado | Ahadmin.h |