CLUSCTL_RESOURCE_GET_RESOURCE_TYPE control code

Retrieves the resource type name for a resource. Applications use this control code as a ClusterResourceControl parameter.



ClusterResourceControl( 
  hResource,                                         // resource handle
  hHostNode,                                         // optional host node
  CLUSCTL_RESOURCE_GET_RESOURCE_TYPE,                // this control code
  NULL,                                              // input buffer (not used)
  0,                                                 // input buffer size (not used)
  lpOutBuffer,                                       // output buffer: string
  cbOutBufferSize,                                   // allocated buffer size (bytes)
  lpcbBytesReturned );                               // actual size of resulting data (bytes)

Parameters

The following control code function parameter is specific to this control code. For complete parameter descriptions, see ClusterResourceControl.

lpOutBuffer

On a successful return, points to a null-terminated Unicode string containing the resource type of the resource.

Return value

ClusterResourceControl returns one of the following values.

ERROR_SUCCESS

0

The operation completed successfully. The lpcbBytesReturned parameter points to the actual size of the returned data.

ERROR_MORE_DATA

234 (0xEA)

More data is available. The output buffer pointed to by lpOutBuffer was not large enough to hold the data resulting from the operation. The lpcbBytesReturned parameter points to the size required for the output buffer.

System error code

If any other value is returned, then the operation failed. The value of lpcbBytesReturned is unreliable.

Remarks

The resource type name is stored in the Type property. This is the registered name of the resource type, such as "File Share" or "Physical Disk", and not the display name. For information on the difference between registered and display names, see Display Names.

Do not use the CLUSCTL_RESOURCE_GET_RESOURCE_TYPE control code in any resource DLL entry point function. This control code can safely be called from a worker thread. For more information, see Function Calls to Avoid in Resource DLLs.

ClusAPI.h defines the 32 bits of CLUSCTL_RESOURCE_GET_RESOURCE_TYPE as follows (for more information, see Control Code Architecture).

ComponentBit locationValue
Object code24–31

CLUS_OBJECT_RESOURCE (0x1)

Global bit23

CLUS_NOT_GLOBAL (0x0)

Modify bit22

CLUS_NO_MODIFY (0x0)

User bit21

CLCTL_CLUSTER_BASE (0x0)

Type bit20

External (0x0)

Operation code0–23

CLCTL_GET_RESOURCE_TYPE (0x2d)

Access code0–1

CLUS_ACCESS_READ (0x1)

 

Resource DLL Support

The CLUSCTL_RESOURCE_GET_RESOURCE_TYPE control code is handled by the Cluster service and is not passed to resource DLLs.

Examples


#include <windows.h>
#include <ClusApi.h>

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

#include "ClusDocEx.h"

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

#ifndef _CLUSDOCEX_RESGETTYPE_CPP
#define _CLUSDOCEX_RESGETTYPE_CPP

LPWSTR ClusDocEx_ResGetResourceType
(
    IN HRESOURCE hRes,
    IN HNODE     hNode
)
// ====================================================================
// 
// Description:
// 
//     Retrieves the resource type of a resource
//     using CLUSCTL_RESOURCE_GET_RESOURCE_TYPE.
// 
// >!! Call LocalFree on the returned pointer to free the memory. !!<
// 
// 
// Arguments:
// 
//    IN HRESOURCE hRes           Handle to the resource to query.
//                                
//    IN HNODE     hNode          Handle to the node to perform the
//                                operation or NULL to default to
//                                the owner node.
// 
// 
// Return Value:
// 
//    If successful, returns a string specifying the resource type
//    of the resource identified by hRes.
// 
//    If unsuccessful, returns a NULL pointer; 
//    call GetLastError() for details.
// 
// 
// Local Variables:
// 
//    dwResult        Captures return values.
//    cbBufSize       Allocated byte size of the output buffer.
//    cbDataSize      Actual byte size of the resulting data.
//    lpszType        Output buffer for the control code operation.
//    dwControlCode   Specifies the operation to perform.
// 
// ====================================================================
{
    DWORD  dwResult      = ERROR_SUCCESS;
    DWORD  cbBufSize     = ClusDocEx_DEFAULT_CB;
    DWORD  cbDataSize    = 0;
    LPWSTR lpszType      = NULL;
    DWORD  dwControlCode = CLUSCTL_RESOURCE_GET_RESOURCE_TYPE;

    lpszType = (LPWSTR) LocalAlloc( LPTR, cbBufSize );

    if( lpszType == NULL )
    {
        dwResult = GetLastError();
        goto endf;
    }

//
//  1.  Call the control code function:  
//
    dwResult = ClusterResourceControl(
                   hRes,            // Resource to query.
                   hNode,           // Node to perform operation.
                   dwControlCode,   // Control code.
                   NULL,            // Input buffer (not used).
                   0,               // Input buffer size (not used).
                   (LPVOID)lpszType,// Output buffer.
                   cbBufSize,       // Byte size of the buffer.
                   &cbDataSize      // Byte size of the resulting data.
               );

//
//  2.  Reallocate if necessary. If the buffer was too small, 
//      cbDataSize now indicates the necessary byte size.
//
    if ( dwResult == ERROR_MORE_DATA )
    {
        LocalFree( lpszType );

        cbBufSize = cbDataSize;

        lpszType = (LPWSTR) LocalAlloc( LPTR, cbBufSize );

        if( lpszType == NULL )
        {
            dwResult = GetLastError();
            goto endf;
        }

        dwResult =
            ClusterResourceControl(
                   hRes,            // Resource to query.
                   hNode,           // Node to perform operation.
                   dwControlCode,   // Control code.
                   NULL,            // Input buffer (not used).
                   0,               // Input buffer size (not used).
                   (LPVOID)lpszType,// Output buffer.
                   cbBufSize,       // Byte size of the buffer.
                   &cbDataSize      // Byte size of the resulting data.
            );

    }

//
//  3.  Handle errors.
//
    if( dwResult != ERROR_SUCCESS )
    {
        LocalFree( lpszType );
        lpszType = NULL;
    }


endf:

    SetLastError( dwResult );

    return lpszType;  // Call LocalFree to release the memory.

}

#endif

// end ClusDocEx_ResGetType


Requirements

Minimum supported client

None supported

Minimum supported server

Windows Server 2008 Enterprise, Windows Server 2008 Datacenter

Header

ClusAPI.h

See also

External Resource Control Codes
ClusterResourceControl
ResourceControl
Type

 

 

Show: