Microsoft Internet Security and Acceleration Server 2000

Loading and Displaying the Filter Configuration

Note that the fields on the property page you will create are based on information extracted from FPCApplicationFilter.VendorParametersSets. The FPCApplicationFilter object is identified by the filter GUID, and is created when a user accesses the filter node in the ISA MMC snap-in. When the property page is created, it runs on a separate thread from that of the FPCApplicationFilter object. For this reason, part of the code provided in this example uses marshalling techniques so that pointers can be passed between these two threads.

To load and display the filter configuration

  1. In order to read the values stored in the filter vendor parameter set, add the following function to your project:
    HRESULT GetVendorData(FPCLib::IFPCApplicationFilterPtr spiApplicationFilter,
    				_bstr_t* pbsVirusString,
    				_bstr_t* pbsPrefixString)
    {
    	HRESULT hr = S_OK;
    	FPCLib::IFPCVendorParametersSetsPtr spIFPCVendorParametersSets;
    	FPCLib::IFPCVendorParametersSetPtr spIFPCVendorParametersSet;
     
    
    	try
    	{
    		spIFPCVendorParametersSet = spiApplicationFilter->VendorParametersSets->Item(_bstr_t(PARAM_SET_GUID));
    		*pbsVirusString  = spIFPCVendorParametersSet->Value[_bstr_t("VirusString")];
    		*pbsPrefixString = spIFPCVendorParametersSet->Value[_bstr_t("PrefixString")];
    ;
    }
    	catch(_com_error& err)
    	{
    		return err.Error();
    }
     
    	return S_OK;
    }
    
  2. You need to add code that will call GetVendorData() and display the received data on the property page. Create the OnInitDialog method by using the message-handler wizard. Do this in the same way that you create other message handlers: Use the dialog box itself as the control in the Class or object to handle list and the WM_INITDIALOG message as the event. Add the following code to the generated code (the m_hWnd serves as a handle to the property page; use it when you need to access any of the controls on the property page):
    		HRESULT hr;
     
    		_bstr_t bsVirusString, bsPrefixString;
    	// Unmarshall an object interface pointer.
    	hr =  CoGetInterfaceAndReleaseStream(
    					m_spStreamMarshalApplicationFilter,
    					FPCLib::IID_IFPCApplicationFilter,
    					(void**)&m_spiApplicationFilter);
     
    	// CoGetInterfaceAndReleaseStream releases m_spStreamMarshalApplicationFilter even if it fails.
    	// We set it to NULL so that the destructor doesn't try to release this again.
    	m_spStreamMarshalApplicationFilter.p = NULL;
     
    	if (FAILED(hr) || !m_spiApplicationFilter.operator bool())
    		return hr;
     
    		hr = ::GetVendorData (m_spiApplicationFilter, &bsVirusString, &bsPrefixString);
    		if (FAILED (hr))
    		{
    			bsVirusString  = "Default Virus String";
    			bsPrefixString = "Default Prefix String";
    	}
     
    		::SetWindowText (::GetDlgItem (m_hWnd, IDC_VIRUS_STRING),  bsVirusString);
    		::SetWindowText (::GetDlgItem (m_hWnd, IDC_PREFIX_STRING), bsPrefixString);
    
  3. Add initialization method for the class SmtpFltrSnapInPage:
    //This method is used for passing a pointer to the ApplicationFilter object of the SMTP filter
    	HRESULT Initialize(FPCLib::IFPCApplicationFilterPtr DataSource)
    	{
    		HRESULT hr=S_OK;
    	
    		hr = CoMarshalInterThreadInterfaceInStream(FPCLib::IID_IFPCApplicationFilter,
    					(IUnknown *)DataSource,
    					&m_spStreamMarshalApplicationFilter);
     
    		return hr;
    }
    
  4. Add the two following private members for the class:
    private:
    	FPCLib::IFPCApplicationFilterPtr m_spiApplicationFilter;
    		// Pointer to stream into which this page's IApplicationFilter object interface
    		// pointer will be marshaled.
    		CComPtr<IStream> m_spStreamMarshalApplicationFilter;
    
  5. Check whether the page was created and initialize the page.
  6. Add the code that is shown in bold font to SmtpFltrSnapIn.cpp.
    HRESULT CSmtpFltrSnapInExtData::CreatePropertyPages(LPPROPERTYSHEETCALLBACK lpProvider,
    	long handle, 
    	IUnknown* pUnk,
    	DATA_OBJECT_TYPES type)
    {
    HRESULT hr;
    	// if (type == CCT_SCOPE || type == CCT_RESULT) 
    	{
    		CSmtpFltrSnapInPage* pPage = new CSmtpFltrSnapInPage(handle, true, _T("SmtpFltrSnapIn"));
    	if (bstrGUID == _bstr_t("{179A0A70-1EF5-11D3-B160-00A0C9E3F998}"))  // Smtp Filter GUID
    		//Check whether the page was created
    		if(pPage == NULL)
    			return E_UNEXPECTED;
    		//Initialize the page.
    		if (FAILED(hr=pPage->Initialize(spiApplicationFilter)))
    			return hr;
    		lpProvider->AddPage(pPage->Create());
    		// The second parameter to the property page class constructor
    		// should be true for only one page.
     
    		// TODO : Add code here to add additional pages
    		return S_OK;
    }
    	return E_UNEXPECTED;
    }