MSSQLWIKI

Karthick P.K on SQL Server

How to get the current state of cluster resource?

Posted by Karthick P.K on December 9, 2010

#include <windows.h> 
#include <ClusApi.h>
#include <winbase.h> 
#include <iostream> 
using namespace std;
#pragma comment(lib,"ClusApi.lib")
#include <stdlib.h>

void main()
{
    HCLUSTER Clusterhandle=NULL; 
    HRESOURCE  ClusterRhandle=NULL; 
    LPCWSTR lpszClusterName =NULL;
    WCHAR *lpszResourceName;
    CLUSTER_RESOURCE_STATE A = ClusterResourceStateUnknown;
    lpszResourceName =new WCHAR;
    wcout<<"enter the name of cluster resource:";
    wcin.getline (lpszResourceName,256);
    Clusterhandle= OpenCluster(lpszClusterName);
    if (Clusterhandle!=NULL)
    {
    
        ClusterRhandle=OpenClusterResource(Clusterhandle,lpszResourceName);
        if (ClusterRhandle!=NULL)
        {
         printf("Got Cluster resource handle\n");
            
         A= GetClusterResourceState(ClusterRhandle,NULL,NULL,NULL,NULL);

         if (A!=ClusterResourceStateUnknown)
             {
             printf("ClusterResourceState is:%d",A);
         
              }
              else
              {
              printf("ClusterResourceState is unknowm",GetLastError());
              
              }
              
        }
        else
        {
        printf("Unable to get ClusterRhandle:%d",GetLastError());
        }
    }
    else 
    {
    printf ("unable to get handle to cluster",GetLastError());
    }
 
}
About these ads

One Response to “How to get the current state of cluster resource?”

  1. […] How to get the current state of cluster resource? […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.

Join 2,135 other followers

%d bloggers like this: