Example #1
0
/////////////////////////////////////////////////////////////////////////////
//++
//
//	CBasePropertyPage::BInit
//
//	Routine Description:
//		Initialize the page.
//
//	Arguments:
//		peo			[IN OUT] Pointer to the extension object.
//
//	Return Value:
//		TRUE		Page initialized successfully.
//		FALSE		Page failed to initialize.
//
//--
/////////////////////////////////////////////////////////////////////////////
BOOL CBasePropertyPage::BInit(IN OUT CExtObject * peo)
{
	ASSERT(peo != NULL);

	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	CWaitCursor	wc;

	m_peo = peo;

	// Don't display a help button.
	m_psp.dwFlags &= ~PSP_HASHELP;

	// Construct the property page.
	if (Peo()->BWizard())
	{
		ASSERT(IddWizardPage() != NULL);
		Construct(IddWizardPage(), IdsCaption());
	}  // if:  adding page to wizard
	else
	{
		ASSERT(IddPropertyPage() != NULL);
		Construct(IddPropertyPage(), IdsCaption());
	}  // else:  adding page to property sheet

	// Read the properties private to this resource and parse them.
	{
		DWORD			dwStatus;
		CClusPropList	cpl;

		ASSERT(Peo() != NULL);
		ASSERT(Peo()->PodObjData());

		// Read the properties.
		switch (Cot())
		{
			case CLUADMEX_OT_NODE:
				ASSERT(Peo()->PndNodeData()->m_hnode != NULL);
				dwStatus = cpl.DwGetNodeProperties(
										Peo()->PndNodeData()->m_hnode,
										CLUSCTL_NODE_GET_PRIVATE_PROPERTIES
										);
				break;
			case CLUADMEX_OT_GROUP:
				ASSERT(Peo()->PgdGroupData()->m_hgroup != NULL);
				dwStatus = cpl.DwGetGroupProperties(
										Peo()->PgdGroupData()->m_hgroup,
										CLUSCTL_GROUP_GET_PRIVATE_PROPERTIES
										);
				break;
			case CLUADMEX_OT_RESOURCE:
				ASSERT(Peo()->PrdResData()->m_hresource != NULL);
				dwStatus = cpl.DwGetResourceProperties(
										Peo()->PrdResData()->m_hresource,
										CLUSCTL_RESOURCE_GET_PRIVATE_PROPERTIES
										);
				break;
			case CLUADMEX_OT_RESOURCETYPE:
				ASSERT(Peo()->PodObjData()->m_strName.GetLength() > 0);
				dwStatus = cpl.DwGetResourceTypeProperties(
										Hcluster(),
										Peo()->PodObjData()->m_strName,
										CLUSCTL_RESOURCE_TYPE_GET_PRIVATE_PROPERTIES
										);
				break;
			case CLUADMEX_OT_NETWORK:
				ASSERT(Peo()->PndNetworkData()->m_hnetwork != NULL);
				dwStatus = cpl.DwGetNetworkProperties(
										Peo()->PndNetworkData()->m_hnetwork,
										CLUSCTL_NETWORK_GET_PRIVATE_PROPERTIES
										);
				break;
			case CLUADMEX_OT_NETINTERFACE:
				ASSERT(Peo()->PndNetInterfaceData()->m_hnetinterface != NULL);
				dwStatus = cpl.DwGetNetInterfaceProperties(
										Peo()->PndNetInterfaceData()->m_hnetinterface,
										CLUSCTL_NETINTERFACE_GET_PRIVATE_PROPERTIES
										);
				break;
			default:
				ASSERT(0);
		}  // switch:  object type

		// Parse the properties.
		if (dwStatus == ERROR_SUCCESS)
		{
			// Parse the properties.
			try
			{
				dwStatus = DwParseProperties(cpl);
			}  // try
			catch (CMemoryException * pme)
			{
				dwStatus = ERROR_NOT_ENOUGH_MEMORY;
				pme->Delete();
			}  // catch:  CMemoryException
		}  // if:  properties read successfully

		if (dwStatus != ERROR_SUCCESS)
		{
			return FALSE;
		}  // if:  error parsing getting or parsing properties
	}  // Read the properties private to this resource and parse them

	return TRUE;

}  //*** CBasePropertyPage::BInit()
/////////////////////////////////////////////////////////////////////////////
//++
//
//  CBasePropertyPage::HrInit
//
//  Description:
//      Initialize the page.
//
//  Arguments:
//      peoInout
//          Pointer to the extension object.
//
//  Return Value:
//      S_OK
//          Page initialized successfully.
//
//      Other HRESULTs
//          Page failed to initialize.
//
//--
/////////////////////////////////////////////////////////////////////////////
HRESULT
CBasePropertyPage::HrInit(
    CExtObject * peoInout
    )
{
    ASSERT( peoInout != NULL );

    AFX_MANAGE_STATE( AfxGetStaticModuleState() );

    HRESULT         hr = S_OK;
    CWaitCursor     wc;
    DWORD           sc = ERROR_SUCCESS;
    CClusPropList   cpl;

    m_peo = peoInout;

    //
    //  Don't display a help button.
    //

    m_psp.dwFlags &= ~PSP_HASHELP;

    //
    //  Construct the property page.
    //

    if ( Peo()->BWizard() )
    {
        ASSERT( IddWizardPage() != NULL);
        Construct( IddWizardPage(), IdsCaption() );
    } // if: adding page to wizard
    else
    {
        ASSERT( IddPropertyPage() != NULL );
        Construct( IddPropertyPage(), IdsCaption() );
    } // else: adding page to property sheet

    //
    //  Read the properties private to this resource and parse them.
    //

    ASSERT( Peo() != NULL );
    ASSERT( Peo()->PodObjData() );

    //
    //  Read the properties.
    //

    switch ( Cot() )
    {
        case CLUADMEX_OT_CLUSTER:
        {
            CClusterData * pccd = reinterpret_cast< CClusterData * >( Peo()->PodObjData() );
            ASSERT( pccd && (pccd->GetHCluster() != NULL) );
            sc = cpl.ScGetClusterProperties(
                                      pccd->GetHCluster()
                                    , CLUSCTL_CLUSTER_GET_PRIVATE_PROPERTIES
                                    );
            break;
        }
        case CLUADMEX_OT_NODE:
        {
            CNodeData * pcnd = reinterpret_cast< CNodeData * >( Peo()->PodObjData() );
            ASSERT( pcnd && (pcnd->GetHNode() != NULL) );
            sc = cpl.ScGetNodeProperties(
                                      pcnd->GetHNode()
                                    , CLUSCTL_NODE_GET_PRIVATE_PROPERTIES
                                    );
            break;
        }
        case CLUADMEX_OT_GROUP:
        {
            CGroupData * pcgd = reinterpret_cast< CGroupData * >( Peo()->PodObjData() );
            ASSERT( pcgd && (pcgd->GetHGroup() != NULL) );
            sc = cpl.ScGetGroupProperties(
                                      pcgd->GetHGroup()
                                    , CLUSCTL_GROUP_GET_PRIVATE_PROPERTIES
                                    );
            break;
        }
        case CLUADMEX_OT_RESOURCE:
        {
            CResData * pcrd = reinterpret_cast< CResData * >( Peo()->PodObjData() );
            ASSERT( pcrd && (pcrd->GetHResource() != NULL) );
            sc = cpl.ScGetResourceProperties(
                                      pcrd->GetHResource()
                                    , CLUSCTL_RESOURCE_GET_PRIVATE_PROPERTIES
                                    );
            break;
        }
        case CLUADMEX_OT_RESOURCETYPE:
        {
            CResTypeData * pcrd = reinterpret_cast< CResTypeData * >( Peo()->PodObjData() );
            ASSERT( pcrd && (pcrd->StrName().GetLength() > 0) );
            sc = cpl.ScGetResourceTypeProperties(
                                      Hcluster()
                                    , pcrd->StrName()
                                    , CLUSCTL_RESOURCE_TYPE_GET_PRIVATE_PROPERTIES
                                    );
            break;
        }
        case CLUADMEX_OT_NETWORK:
        {
            CNetworkData * pcnd = reinterpret_cast< CNetworkData * >( Peo()->PodObjData() );
            ASSERT( pcnd && (pcnd->GetHNetwork() != NULL) );
            sc = cpl.ScGetNetworkProperties(
                                      pcnd->GetHNetwork()
                                    , CLUSCTL_NETWORK_GET_PRIVATE_PROPERTIES
                                    );
            break;
        }
        case CLUADMEX_OT_NETINTERFACE:
        {
            CNetInterfaceData * pcnd = reinterpret_cast< CNetInterfaceData * >( Peo()->PodObjData() );
            ASSERT( pcnd && (pcnd->GetHNetInterface() != NULL) );
            sc = cpl.ScGetNetInterfaceProperties(
                                      pcnd->GetHNetInterface()
                                    , CLUSCTL_NETINTERFACE_GET_PRIVATE_PROPERTIES
                                    );
            break;
        }
        default:
            ASSERT( 0 );
    } // switch: object type

    //
    //  Parse the properties.
    //

    if ( sc == ERROR_SUCCESS )
    {
        // Parse the properties.
        try
        {
            sc = ScParseProperties( cpl );
        } // try
        catch ( CMemoryException * pme )
        {
            hr = E_OUTOFMEMORY;
            pme->Delete();
        } // catch: CMemoryException
    } // if: properties read successfully

    if ( sc != ERROR_SUCCESS )
    {
        hr = HRESULT_FROM_WIN32( sc );
        goto Cleanup;
    } // if: error parsing getting or parsing properties

Cleanup:

    return hr;

} //*** CBasePropertyPage::HrInit