Compartir a través de


Changing the Cluster Configuration with Control Codes

Control codes that send data to the cluster in the control code function's input buffer use the following procedure:

To use an "input" control code

  1. Refer to the control code reference to determine what data must be passed in the input buffer and what the format should be. You may need to construct a value list or property list and pass that as the input buffer. See Creating Property Lists and Creating Value Lists for more information.
  2. Allocate and populate the input buffer.
  3. Call the function.
  4. Test the return value and take appropriate action based on success/failure.

Example

The following example demonstrates the use of the "input" control code CLUSCTL_RESOURCE_SET_NAME.

#include <windows.h>
//////////////////////////////////////////////////////////////////////

#include "ClusDocEx.h"    

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

#ifndef _CLUSDOCEX_RESSETNAME_CPP
#define _CLUSDOCEX_RESSETNAME_CPP

//--------------------------------------------------------------------
//
//  ClusDocEx_SetResourceName
//
//      Changes the name of a resource.
//
//  Arguments:
//
//      HRESOURCE hResource       Handle to the resource.
//
//      LPWSTR    lpszResName     New resource name.
//
//  Return Value:
//
//      If successful, ERROR_SUCCESS, otherwise an error code.
//
//--------------------------------------------------------------------
DWORD ClusDocEx_SetResourceName
(
    HRESOURCE hResource,
    LPWSTR    lpszResName
)
{
    DWORD dwResult = ERROR_SUCCESS;

    if( ( hResource != NULL ) || ( lpszResName != NULL ) )
    {
        DWORD cbNameSize = ( lstrlenW( lpszResName ) + 1 ) * 
                           sizeof( WCHAR );

        dwResult = ClusterResourceControl( hResource,
                                           NULL,
                                           CLUSCTL_RESOURCE_SET_NAME,
                                           lpszResName,
                                           cbNameSize,
                                           NULL,
                                           0,
                                           NULL );

    }
    else
    {
        dwResult = ERROR_BAD_ARGUMENTS;
    }

    return dwResult;
}
#endif