Microsoft Internet Security and Acceleration Server 2000 |
To implement the sample filter and display the filter in the results pane of ISA Management, use the RegisterWebFilter function to register the filter with ISA. This function is also called by the DllRegisterServer and DllUnregisterServer functions.
The following RegisterWebFilter function code is taken from the file WebFltrRegister.cpp, included in the Webresponsemodifier directory:
static HRESULT RegisterWebFilter(bool fRegister) { HRESULT hr; ISALIB::IFPC *pIISA = NULL; // Get instance of filter admin object. hr = CoInitialize(NULL); if (FAILED(hr)) return hr; hr = CoCreateInstance( CLSID_FPC, NULL, CLSCTX_SERVER, IID_IFPC, (void**)&pIISA); if (FAILED(hr)) return hr; ISALIB::IFPCArrays *pIISAArrs = pIISA->Arrays; ISALIB::IFPCArray *pIISAArr = pIISAArrs->GetContainingArray(); ISALIB::IFPCExtensions *pIExtensions = pIISAArr->Extensions; ISALIB::IFPCWebFilters *pWebFilters = pIExtensions->WebFilters; ISALIB::IFPCWebFilter *pFilter = NULL; if (fRegister) { _bstr_t bstr(StrGuid); try { pFilter = pWebFilters->Add(bstr,"ISAPI Filter",FilterRelativePath,ISALIB::fpcFilterPriority_Medium,ISALIB::fpcFilterDirectionBoth); pFilter->PutDescription("Filter Description"); pFilter->PutVendor("Microsoft"); pFilter->PutVersion("1.0"); // pFilter->PutEnabled(TRUE); } catch(_com_error& err) { if(err.Error() != HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS)) { hr = E_FAIL; } } if (pFilter) { pFilter->Save(); } } else { try { pWebFilters->Remove(StrGuid); } catch(_com_error& err) { if(err.Error() != HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)) { hr = E_FAIL; } } } pWebFilters->Save(); pWebFilters->Refresh(); if(pIISA) pIISA->Release(); CoUninitialize( ); return hr; }