Note that the fields on the property page that you will create are based on information extracted from the VendorParametersSets collection associated with the FPCApplicationFilter object. The FPCApplicationFilter object is identified by the filter GUID, and is created when a user accesses the filter node in the Forefront TMG 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
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; }
HRESULT hr = S_OK; _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);
//This method is used for passing a pointer to the FPCApplicationFilter object of the filter HRESULT Initialize(FPCLib::IFPCApplicationFilterPtr DataSource) { HRESULT hr = S_OK; hr = CoMarshalInterThreadInterfaceInStream(FPCLib::IID_IFPCApplicationFilter, (IUnknown*)DataSource, &m_spStreamMarshalApplicationFilter); return hr; }
private: FPCLib::IFPCApplicationFilterPtr m_spiApplicationFilter; // Pointer to stream into which this page's IApplicationFilter object interface // pointer will be marshaled. CComPtr<IStream> m_spStreamMarshalApplicationFilter;
HRESULT CFilterSnapInExtData::CreatePropertyPages(LPPROPERTYSHEETCALLBACK lpProvider, long handle, IUnknown* pUnk, DATA_OBJECT_TYPES type) { HRESULT hr = S_OK; // if (type == CCT_SCOPE || type == CCT_RESULT) CFilterSnapInPage* pPage = new CFilterSnapInPage(handle, true, _T("FilterSnapIn")); if (bstrGUID == _bstr_t("{7CCF6FF0-D995-4da1-B452-4228047B2D1D}")) // 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; }
Send comments about this topic to Microsoft
Build date: 11/30/2009
© 2008 Microsoft Corporation. All rights reserved.