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;
}
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"));