Jaa


Dynamic Non-Namespace Extensions

This feature is introduced in MMC 1.1.

Using the CCF_MMC_DYNAMIC_EXTENSIONS clipboard format, a snap-in can also add any of the following types of extensions to its own scope or result items:

  • Context menus
  • Toolbars
  • Property sheets
  • Taskpads

For these types of extensions, add the clipboard format CCF_MMC_DYNAMIC_EXTENSIONS to the snap-in's IDataObject implementation for the items you want to extend. The CCF_MMC_DYNAMIC_EXTENSIONS format uses the SMMCDynamicExtensions structure. This structure specifies the extension snap-ins you want to extend the item represented by the IDataObject object.

Be aware that the MMC registry entries for the primary snap-in and the extension snap-in must be set correctly. For details on setting MMC registry entries for namespace extensions, see Registration Requirements for Extension Snap-ins.

The following Steps describe how to implement dynamic extensions for non-namespace extensions:

To implement dynamic extensions for non-namespace extensions

  1. Add the CCF_MMC_DYNAMIC_EXTENSIONS clipboard format to the snap-in's IDataObject implementation.

    Usually, IDataObject has its supported clipboard formats as static members. If so, add the CCF_MMC_DYNAMIC_EXTENSIONS format as a member:

    static UINT s_cfDynamicExtensions;
    

    Register the CCF_MMC_DYNAMIC_EXTENSIONS format and assign the registered format to the static member in the IDataObject implementation's constructor:

    s_cfDynamicExtensions = RegisterClipboardFormat (W2T(CCF_MMC_DYNAMIC_EXTENSIONS));
    
  2. Handle the CCF_MMC_DYNAMIC_EXTENSIONS format in the IDataObject::GetData method.

    The following example handles the CCF_MMC_DYNAMIC_EXTENSIONS format and returns an SMMCDynamicExtensions structure that contains an array of two GUIDs that are the CLSIDs of the two extension snap-ins (CLSID_Snapin1 and CLSID_Snapin2) that will extend the item:

        if (cf == s_cfDynamicExtensions)
        {
          UINT cGuids = 2;
          UINT size = sizeof(SMMCDynamicExtensions) + 
                      (cGuids-1) * sizeof(GUID);
    
          lpMedium->hGlobal = ::GlobalAlloc(GPTR, size);
    
          if (!lpMedium->hGlobal)
              return E_OUTOFMEMORY;
    
          SMMCDynamicExtensions* pdata = 
                     reinterpret_cast<SMMCDynamicExtensions*>
                     (lpMedium->hGlobal);
          pdata->count = cGuids;
          int i=0;
          pdata->guid[i++] = CLSID_Snapin1;
          pdata->guid[i++] = CLSID_Snapin2;
          return S_OK;
        }
    

Just before MMC must use an extensible feature (that is, just before creating and that displays a context menu, property sheet, toolbar, or taskpad), MMC calls IDataObject::GetData on the data object for the selected item and asks for dynamic extensions to add through the CCF_MMC_DYNAMIC_EXTENSIONS clipboard format. Based on the CLSIDs passed in the SMMCDynamicExtensions structure, MMC attempts to add the specified extensions to the extensible feature. If an extension is unavailable or unregistered, MMC skips that extension and continues to the next CLSID passed in the structure.

Adding Dynamic Extensions: Interfaces

Dynamic Namespace Extensions

Working with Extension Snap-ins

MMC Registry Entries