次の方法で共有


Filter Display of Property Pages Using the extid Attribute

The Applications snap-in loads all registered application plug-in property pages when the Applications properties window is displayed. The Applications snap-in extension uses the information from the IXMLDOMDocument, which is returned from the Applications snap-in IDataObject. For more information, see Obtain the IXMLDOMDocument* from the Primary Snap-in's IDataObject. Each Applications snap-in property page inspects the extid attribute to exclude integration with the Applications snap-in unless the root element of the XML document includes the extid attribute of your extension. If extid does not match the registered ExtId for your extension, add no property pages and return S_FALSE. This prevents an extension from displaying incorrect item types.

For more information about the registered ExtId for an extension, see Implement support for Applications snap-in menu integration.

Filter display code example

The code used to perform this operation is available in the AppExt.cpp file provided and can be used without modification. For more information and the code example, see Applications Snap-in Extension Sample Code. If this property page should be displayed, bAddPage will be True.

Note

m_pXmlDom is from the code example in Implement support for Applications snap-in menu integration.

 

if ( SUCCEEDED( hr ) )
   {
      IXMLDOMNode* pAttExtId = NULL;

      // Get the "extid" attribute:
      hr = m_pXmlDom->selectSingleNode( L"/Application/@extid", &pAttExtId );

      if ( hr == S_OK )
      {
         BSTR bstrExtId;

         hr = pAttExtId->get_text( &bstrExtId );

         if ( SUCCEEDED( hr ) )
         {
            // Uses case insensitive comparison: 
            int nResult = _wcsicmp( bstrExtId, g_szwExtId );

            if ( nResult == STRING_MATCH )
            {
               // This is the correct extid. Create the property page:
               bAddPage = true;
            }
            else
            {
               // This is another extid. Do not create the property page:
               bAddPage = false;
            }

            SysFreeString( bstrExtId );
         }

         pAttExtId->Release();
      }
      else
      {
         // The "extid" attribute was not present:
         hr = E_UNEXPECTED;
      }
   }