Share via


System Registry Modifications

When adding Microsoft Management Console (MMC) extension snap-ins it is necessary to make certain system registry modifications. These include the normal Component Object Model (COM) entries in the HKEY_CLASSES_ROOT registry key, as well as the MMC-specific entries in the HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\MMC\\NodeTypes and ...\\MMC\\SnapIns registry keys.

If the new extension snap-in will have child nodes exposed in the scope pane, it is also necessary to add the GUID corresponding to the new extension snap-in to the Extension/NameSpace key of the appropriate NodeType key in the system registry.

Depending on whether the new extension snap-in corresponds to a global resource or a site resource, it will be necessary to modify either the "Microsoft Commerce Server 2000 Group Resources" or the "Microsoft Commerce Server 2000 Resource" NodeType registry entry. For more information about the corresponding NodeType GUIDs, see the first two rows in the table in Commerce Server Manager NodeType GUIDs.

The Site Status sample in the Commerce Server 2000 Software Development Kit (SDK) performs these registry modifications in the file Registry.cpp, and uses some data type information provided in the file Extend.h. The following code excerpt shows the source code that performs these modifications. The excerpt shows a pre-initialized array of EXTENDER_NODE structures, defined in the file Extend.h, and designed to perform a name space extension of the site resources, due to the GUID supplied for the guidNode structure member (unique aspect shown in bold font). To make the same system registry extension for an extension snap-in being added as a global resource, the first component of that GUID would have to be set to 0x1503a832. (The array in the following code excerpt contains one actual entry and one dummy entry, the latter of which is used for loop termination.)

// List all of the nodes that we extend.
EXTENDER_NODE _NodeExtensions[] = {
    {
        // Extension type:
        NameSpaceExtension,
        // "Microsoft Commerce Server 4.0 Site Resources" guid:
        {0x1503a834, 0x6945, 0x11d2,
            { 0xaf, 0xf4, 0x0, 0xc0, 0x4f, 0x86, 0x70, 0xe4 } },
        // CLSID_COpenCloseExtension guid:
        {0xa5ce2b5a, 0x2259, 0x485d,
            { 0x9c, 0x11, 0xa0, 0x20, 0xb7, 0xc3, 0x8e, 0x2f } },
        // Description:
        _T("Commerce 2000 Resource Extension Open/Close sample")
    },

    // Dummy entry for loop termination logic.
    {DummyExtension, NULL, NULL, NULL}
};

The following excerpt shows the for loop that processes the array shown in the previous excerpt. It adds the GUID and description stored in the guidExtension and szDescription structure members as a key/value pair in the Extensions/NameSpace key of the MMC/NodeType entry corresponding to the GUID stored in the guidNode structure member.

Note that the loop terminates when a NULL description is found, as is the case in the last element in the array.

    // register each of the node extensions
    for (pNodeExtension = &(_NodeExtensions[0]) ;
         *pNodeExtension->szDescription ;
         pNodeExtension++)
    {
        hr = StringFromCLSID(pNodeExtension->guidNode, &wszExtendCLSID);
        _tcscpy(szKeyBuf, _T("SOFTWARE\\Microsoft\\MMC\\NodeTypes\\"));
        _tcscat(szKeyBuf, wszExtendCLSID);

        switch (pNodeExtension->eType) {
        case NameSpaceExtension:
            _tcscat(szKeyBuf, _T("\\Extensions\\NameSpace"));
            break;
        default:
            break;
        }

        // Create and open key and subkey.
        long lResult = RegCreateKeyEx(HKEY_LOCAL_MACHINE ,
            szKeyBuf,
            0, NULL, REG_OPTION_NON_VOLATILE,
            KEY_ALL_ACCESS, NULL,
            &hKey, NULL) ;

        if (lResult != ERROR_SUCCESS)
        {
            return FALSE ;
        }

        hr = StringFromCLSID(pNodeExtension->guidExtension,
                             &wszNodeCLSID);
        assert(SUCCEEDED(hr));

        // Set the Value.
        if (pNodeExtension->szDescription != NULL)
        {
            RegSetValueEx(hKey, wszNodeCLSID, 0, REG_SZ,
                          (BYTE *)pNodeExtension->szDescription,
                          (_tcslen(pNodeExtension->szDescription)+1)
                                                     *sizeof(_TCHAR));
        }

        RegCloseKey(hKey) ;

        CoTaskMemFree(wszExtendCLSID);
        CoTaskMemFree(wszNodeCLSID);
    }


All rights reserved.