Previous in Contents Next in Contents

Accessing an IExtensions Interface Object

You access an IExtensions interface object by calling the IBuildCatalog.Extensions property, as in the following example, where objExtensions is the name you give to the IExtensions interface object:

Option Explicit 
On Error Resume Next 

sub Error (Number, Message)
    Wscript.echo "Error #" & Number & " (0x" & Hex(Number) & ") received " & Message
end sub

const NOERROR             = 0

Dim objSearchAdmin, objBuildCatalog, objExtensions, objExtension, Inc 
Dim Found 
Found = False

Set objSearchAdmin   = CreateObject("Search.SearchAdmin.1") 

For Each objBuildCatalog in objSearchAdmin.BuildServer.BuildCatalogs
  Set objExtensions = objBuildCatalog.Extensions 

  For Each objExtension in objExtensions

    If objExtension.Extension = "tmp" Then
      Found = True
      Exit For
    End If
  Next

  If objExtensions.IncludedExtensions Then
    Inc = "included"
    ' Remove it from the list of files Search crawls
    If Found Then objExtensions.Remove("tmp") 
  Else
    Inc = "excluded"
    ' Add it to the list of files Search does not crawl
    If NOT Found Then objExtensions.Add("tmp")
  End If

  Wscript.Echo "There are " & objExtensions.Count & " extensions " _
    & Inc & " for " & objBuildCatalog.Name & ":"
  
  For Each objExtension in objExtensions
    Wscript.Echo "  " & objExtension.Extension
  Next
  
  Wscript.Echo ""
Next

'Release objects 
Set objExtension     = Nothing 
Set objExtensions    = Nothing 
Set objBuildCatalog  = Nothing 
Set objSearchAdmin   = Nothing 
 

© 1997-2000 Microsoft Corporation. All rights reserved.