Partager via


Read Property Data

When an extension to the Applications snap-in property sheet is displayed, each property page reads its properties from the Properties XML element.

Code Example

The code to read property data is available in the AppExt.cpp. The following code example shows a simple registry property connected to a checkbox control. To read the properties reflected by the controls on your property page, replace this with your own code.

                 
         IXMLDOMNode* pElmExampleProp = NULL;

         // Find the "Reg" property element:
         HRESULT hr = pThis->m_pXmlDom->selectSingleNode( 
            L"/Application/Properties/Reg[@id='exampleSetting']", 
            &pElmExampleProp );
         
         if ( hr == S_OK )
         {
            BSTR bstrValue;
            
            // Get the registry property value:
            GetAttribute( pElmExampleProp, _T( "value" ), bstrValue );

            int nResult = _wcsicmp( bstrValue, _T( "1" ) );
            
            bool bChecked =  ( nResult == STRING_MATCH );

            // Set the state of the control:
            CheckDlgButton( hwndDlg, IDC_CHECK1, 
               bChecked ? BST_CHECKED : BST_UNCHECKED ); 

            pElmExampleProp->Release();
            ::SysFreeString(bstrValue);
         }
         else
         {
            // Set the default state of the control:
            CheckDlgButton( hwndDlg, IDC_CHECK1, BST_UNCHECKED ); 
         }