Microsoft Internet Security and Acceleration Server 2000

Displaying the Adapters

The following code works with the MMC console to show the adapters. This code is taken from the file Adapters.cpp in the sample directory, is written by the Active Template Library (ATL) object wizard and is used at the start of development.

To use the ATL object wizard

  1. Open Microsoft Visual C++.
  2. Click New ATL Object on the Insert menu.
  3. Select MMC Snapin from the Objects list.
  4. Click Next.
  5. Type Adapters in the ShortName box on the Names tab.
  6. Select the Extension and IExtendcontextmenu check boxes on the MMC Snapin tab. (Be sure to leave IComponentData, IComponent, and ISnapInAbout checked.).
  7. Clear the Support Persistence check box.
  8. On the MMC Snapin tab, in the Extends Node box, select the node you want to extend(servers).

The wizard produces the following code.

HRESULT CAdaptersData::Notify( MMC_NOTIFY_TYPE event,
	long arg,
	long param,
	IComponentData* pComponentData,
	IComponent* pComponent,
	// Add code to handle the different notifications.
	// Handle MMCN_SHOW and MMCN_EXPAND to enumerate child items.
	// In response to MMCN_SHOW you must enumerate both the scope
	// and result-pane items.
	// For MMCN_EXPAND you only need to enumerate the scope items
	// Use IConsoleNameSpace::InsertItem to insert scope pane items
	// Use IResultData::InsertItem to insert result pane item.
	_ASSERTE(pComponentData != NULL || pComponent != NULL);
	CComPtr<IConsole> spConsole;
	CComQIPtr<IHeaderCtrl, &IID_IHeaderCtrl> spHeader;
	if (pComponentData != NULL)
		spConsole = ((CAdapters*)pComponentData)->m_spConsole;
		spConsole = ((CAdaptersComponent*)pComponent)->m_spConsole;
		spHeader = spConsole;
	switch (event)
	case MMCN_SHOW:
			CComQIPtr<IResultData, &IID_IResultData> spResultData(spConsole);
			// TODO : Enumerate the result pane items
			hr = S_OK;
			CComQIPtr<IConsoleNameSpace, &IID_IConsoleNameSpace> spConsoleNameSpace(spConsole);
			// TODO : Enumerate scope pane items
			hr = S_OK;
			// Add Images
			IImageList* pImageList = (IImageList*) arg;
			hr = E_FAIL;
			// Load bitmaps associated with the scope pane
			// and add them to the image list
			// Loads the default bitmaps generated by the wizard
			// Change as required
			HBITMAP hBitmap16 = LoadBitmap(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDB_ADAPTERS_16));
			if (hBitmap16 != NULL)
				HBITMAP hBitmap32 = LoadBitmap(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDB_ADAPTERS_32));
				if (hBitmap32 != NULL)
					hr = pImageList->ImageListSetStrip((long*)hBitmap16, 
					(long*)hBitmap32, 0, RGB(0, 128, 128));
					if (FAILED(hr))
						ATLTRACE(_T("IImageList::ImageListSetStrip failed\n"));
	return hr;