Compartir a través de


Función ResUtilPropertyListFromParameterBlock (resapi.h)

Construye una lista de propiedades a partir de una tabla de propiedades y un bloque de parámetros.

Sintaxis

DWORD ResUtilPropertyListFromParameterBlock(
  [in]            const PRESUTIL_PROPERTY_ITEM pPropertyTable,
  [out, optional] PVOID                        pOutPropertyList,
  [in, out]       LPDWORD                      pcbOutPropertyListSize,
  [in]            const LPBYTE                 pInParams,
  [out]           LPDWORD                      pcbBytesReturned,
  [out]           LPDWORD                      pcbRequired
);

Parámetros

[in] pPropertyTable

Puntero a una tabla de propiedades que describe las propiedades que se incluirán en la lista de propiedades resultante.

[out, optional] pOutPropertyList

Puntero a un búfer de salida que recibe la lista de propiedades.

[in, out] pcbOutPropertyListSize

Puntero al tamaño del búfer de salida en bytes.

[in] pInParams

Puntero al bloque de parámetros en el que se almacenan los valores de propiedad.

[out] pcbBytesReturned

Si la función devuelve ERROR_SUCCESS, pcbBytesReturned apunta al tamaño de byte real de la lista de propiedades a la que apunta pOutPropertyList. Si la función no devuelve ERROR_SUCCESS, pcbBytesReturned apunta a un valor de cero.

[out] pcbRequired

Si la función devuelve ERROR_MORE_DATA, pcbRequired apunta al tamaño de byte necesario para contener la lista de propiedades. Si la función no devuelve ERROR_MORE_DATA, pcbBytesReturned apunta a un valor de cero.

Valor devuelto

Si la operación se realiza correctamente, la función devuelve ERROR_SUCCESS.

Si se produce un error en la operación, la función devuelve un código de error del sistema. A continuación se muestran códigos de error posibles.

Código devuelto Descripción
ERROR_MORE_DATA
El búfer de salida es demasiado pequeño para contener la lista de propiedades resultante.
ERROR_BAD_ARGUMENTS
Uno o varios de los parámetros de entrada no eran válidos.
ERROR_NOT_ENOUGH_MEMORY
Error al asignar memoria.

Comentarios

En esta función, la tabla de propiedades determina el orden en el que aparecen las propiedades en la lista de propiedades, así como el nombre y el formato de cada propiedad. La función lee la tabla de propiedades para determinar el nombre y el formato de cada propiedad.

El bloque de parámetros proporciona los valores de propiedad.

Ejemplos

En el ejemplo siguiente se definen tres propiedades (Protocol, PortNumber y ConnectionName). Usa la función ResUtilPropertyListFromParameterBlock para crear una lista de propiedades. En este ejemplo se usa el archivo de encabezado ClusDocEx.h definido en la documentación del clúster de conmutación por error.

//////////////////////////////////////////////////////////////////////

//  Be sure to create the following file before you compile.
//  For a code listing, see "ClusDocEx.h".
    #include "ClusDocEx.h"

//////////////////////////////////////////////////////////////////////

//  This example defines three fictional properties: 
//      Protocol (DWORD)
//      PortNumber (DWORD)
//      ConnectionName (PWSTR)
//  These properties are not associated with any cluster object.
//  They are used only to demonstrate the
//  ResUtilPropertyListFromParameterBlock function.

//  Protocol property constants
    #define PROP_NAME__PROTOCOL       L"Protocol"
    typedef enum PROTOCOLS{
        PROTOCOL_NONE = 0,
        PROTOCOL_BOTH = 1,
        PROTOCOL_TCP  = 2,
        PROTOCOL_UDP  = 3
    };
    #define PROP_MIN__PROTOCOL       (PROTOCOL_NONE)
    #define PROP_MAX__PROTOCOL       (PROTOCOL_UDP)
    #define PROP_DEFAULT__PROTOCOL   (PROTOCOL_BOTH)

//  PortNumber property
    #define PROP_NAME__PORTNUMBER     L"PortNumber"
    #define PROP_MIN__PORTNUMBER      (0)
    #define PROP_MAX__PORTNUMBER      (65536)
    #define PROP_DEFAULT__PORTNUMBER  (80)

//  ConnectionName property
    #define PROP_NAME__CONNECTIONNAME L"ConnectionName"

//  Parameter block
    typedef struct _PARAMBLOCK{
        DWORD dwProtocol;
        DWORD dwPortNumber;
        PWSTR pszConnectionName;
    } PARAMBLOCK; 
    
//  Property table
    RESUTIL_PROPERTY_ITEM
    pPropTable[] =
    {
        {   PROP_NAME__PROTOCOL, 
            NULL, 
            CLUSPROP_FORMAT_DWORD, 
            PROP_DEFAULT__PROTOCOL, 
            PROP_MIN__PROTOCOL, 
            PROP_MAX__PROTOCOL, 
            RESUTIL_PROPITEM_REQUIRED,  
            FIELD_OFFSET( _PARAMBLOCK, dwProtocol )        },

        {   PROP_NAME__PORTNUMBER,
            NULL, 
            CLUSPROP_FORMAT_DWORD, 
            PROP_DEFAULT__PORTNUMBER, 
            PROP_MIN__PORTNUMBER, 
            PROP_MAX__PORTNUMBER, 
            RESUTIL_PROPITEM_REQUIRED, 
            FIELD_OFFSET( _PARAMBLOCK, dwPortNumber )      },

        {   PROP_NAME__CONNECTIONNAME, 
            NULL, 
            CLUSPROP_FORMAT_SZ, 
                0, 0, 0, 0,
            FIELD_OFFSET( _PARAMBLOCK, pszConnectionName ) },

        { 0 }
    };

    int main()
    {
        DWORD nResult    = ERROR_SUCCESS,
              cbBufSize  = 1024,
              cbReturned = 0,
              cbRequired = 0;

        PVOID pPropList = LocalAlloc( LPTR, cbBufSize );

    //  Values for the property list
        PARAMBLOCK NewParams = { PROTOCOL_TCP, 21, L"FTP" };

        nResult = ResUtilPropertyListFromParameterBlock(
                      pPropTable,
                      pPropList,
                      &cbBufSize,
                      (LPBYTE) &NewParams,
                      &cbReturned,
                      &cbRequired );

        if( nResult == ERROR_MORE_DATA )
        {
            LocalFree( pPropList );

            cbBufSize = cbRequired;
            
            pPropList = LocalAlloc( LPTR, cbBufSize );

            nResult = ResUtilPropertyListFromParameterBlock(
                          pPropTable,
                          pPropList,
                          &cbBufSize,
                          (PBYTE) &NewParams,
                          &cbReturned,
                          &cbRequired );
        }

        ClusDocEx_DebugPrint( L"Results:", nResult );

        if( nResult == ERROR_SUCCESS )
            ClusDocEx_ShowBuffer( pPropList, cbReturned );    
    
        LocalFree( pPropList );
    
        return (int)( nResult != ERROR_SUCCESS );    
    }

Requisitos

Requisito Value
Cliente mínimo compatible No se admite ninguno
Servidor mínimo compatible Windows Server 2008 Enterprise, Windows Server 2008 Datacenter
Plataforma de destino Windows
Encabezado resapi.h
Library ResUtils.lib
Archivo DLL ResUtils.dll

Consulte también

RESUTIL_PROPERTY_ITEM