Hi,
I have two questions to ask:
-
When I enumerate Physical Disk Resources I get something like "Disk G: "
as the name of the resource. Is this resource name a reliable source to pick
the drive letter from ? -
I am not getting any of the clusters being reported with the following
approach . What could be wrong in the code?
Thnaks in advance.
Regards,
Arati
The code:
////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////
#include <windows.h>
#include <clusapi.h>
#include <resapi.h>
#include
#include
#include “ClusterResourceCtlInterface.h”
//for enum
//#include <chstring.h> //for CHString
using namespace std;
DWORD
MyCallbackFunction( HRESOURCE hSelf,
HRESOURCE hCurrentEnum,
PVOID pData );
bool getDriveLetter(string& var);
LPRESOURCE_CALLBACK g_pMyCallbackFunction = &MyCallbackFunction;
---------------------------------------------------------------------
int main (void)
{
//string strResType(“Physical Disk”); //getting all the physical disks
DWORD dwResult = ResUtilEnumResources(
0,
0,
//L"Physical Disk",
//reinterpret_cast(strResType.c_str()),
//Arati try L"Physical Disk"
g_pMyCallbackFunction,
NULL );
if( dwResult != ERROR_SUCCESS )
{
printf( “ResUtilEnumResources returned an error. %d”, dwResult );
return 1;
}
else
return 0;
}
-----------------------------------------------------------------------
DWORD MyCallbackFunction( HRESOURCE hSelf, HRESOURCE hCurrentEnum, PVOID
pData )
{
DWORD dwResult = ERROR_SUCCESS;
cout << “\n In call back function”;
DWORD cbListSize;
LPVOID lpValueList = ClusDocEx_ResGetControlCodeOutput(hCurrentEnum,
0,
CLUSCTL_RESOURCE_TYPE_STORAGE_GET_AVAILABLE_DISKS,
&cbListSize);
// Parse the buffer. The control code returns a value list.
CLUSPROP_BUFFER_HELPER cbh;
cbh.pb = (PBYTE) lpValueList;
DWORD cbPosition = 0;
while( 1 )
{
if( ( cbh. pPartitionInfoValue->Syntax.dw ==
CLUSPROP_SYNTAX_PARTITION_INFO ))
{
cout << “\n- Partition info found”;
cout << "\n\tThe drive letter is ";
cout << cbh. pPartitionInfoValue-> szDeviceName;
}
else if( cbh.pSyntax->dw == CLUSPROP_SYNTAX_ENDMARK )
// Reached the end of the list.
break;
// Add the size of the current entry to the position indicator
cbPosition += ClusDocEx_ListEntrySize( cbh.pValue->cbLength );
// Compare position indicator to the size of the list.
// Adding sizeof( DWORD ) allows for the read operation at the
// top of the loop.
if( ( cbPosition + sizeof( DWORD ) ) > cbListSize )
break;
// Advance cbh
cbh.pb += ClusDocEx_ListEntrySize( cbh.pValue->cbLength );
}
// End while.
return 1;
}
--------------------------------------------------------------</chstring.h></resapi.h></clusapi.h></windows.h>