CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2011
    Posts
    6

    Need Help With Cluster Manager API function: OpenClusterResource

    I'm trying to write a C++ to help manage services in Failover Cluster Manager.

    The code below works, but I don't want to use wcin.getline to assign a string to lpszResourceName.

    How can I assign a string to lpszResourceName?

    I've tried many different ways and conversions, but nothing works.

    HCHANGE hChange = (HCHANGE)INVALID_HANDLE_VALUE;
    HRESOURCE hResource = NULL;
    DWORD dwFilterType;
    DWORD dwNotifyKey;
    DWORD dwStatus;
    DWORD cchNameSize = ClusDocEx_DEFAULT_CCH;
    LPWSTR pszObjectName = new WCHAR[cchNameSize];
    WCHAR *lpszResourceName;
    lpszResourceName =new WCHAR;
    bool bExit = false;

    CLUSTER_RESOURCE_STATE resource_state = ClusterResourceStateUnknown;

    char *str1 ="Oralce Process Manager (EPM_epmsystem1)";
    swprintf(lpszResourceName,L"%s",str1);

    wcout << "Enter the name of cluster resource: ";
    wcin.getline(lpszResourceName,256);

    if(hCluster != NULL)
    {
    cout << lpszResourceName << endl;

    hResource=OpenClusterResource((HCLUSTER) hCluster, lpszResourceName);
    //hResource=OpenClusterResource((HCLUSTER) hCluster,lpszResourceName);

    if(hResource != NULL)
    cout << "Thread: Got resource handle." << endl << endl;
    else
    cout << "Thread: No resource handle." << endl << endl;
    }

  2. #2
    Join Date
    Jan 2011
    Posts
    6

    Cool Re: Need Help With Cluster Manager API function: OpenClusterResource

    So this is the solution I found that didn't involve crazy blocks of code.
    All I had to do was use _T to pass in the string I wanted.

    hResource=OpenClusterResource((HCLUSTER) hCluster, _T("My Service"));

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured