Previous in Contents Next in Contents

Accessing ReplicationEventSinkConfig Objects

You access an existing ReplicationEventSinkConfig object (event sink) by calling the ReplicationServer.EnumEventSinks method, as in the following example, where ReplSink is the name of the ReplicationEventSinkConfig object:

Option Explicit 
On Error Resume Next

const CRS_ERROR_NO_MORE_ITEMS  = 0&80003B17

dim ReplServer
set ReplServer = CreateObject("CrsApi.ReplicationServer")
ReplServer.Initialize("")

dim Iterator
Iterator = 0
dim ReplSink

do while True
  'Clear any error text
  Err.Clear
  'Get an event sink
  set ReplSink = ReplServer.EnumEventSinks(Iterator)
  'Quit if empty object returned
  if IsEmpty(ReplSink) then
    Wscript.Echo "Empty object returned for event sink"
    exit do
  end if

'Quit if "No more items" error 
  dim ReplError
  ReplError = Err.Number
  if ReplError = CRS_ERROR_NO_MORE_ITEMS then exit do
  'If some other error, display the number and exit
  if ReplError > 0 then
   Wscript.Echo "Error: " & ReplError
  end if
  if ReplSink.CLSID = "NT" then 
    dim GotIt
    GotIt = True
    ReplSink.ProjectFilter("Project1")
  end if
Loop

if GotIt = False then
  Wscript.Echo "The event sink monitor is not monitoring events."
else
  Wscript.Echo "The event sink monitor is monitoring events." 
end if

'Release objects
set ReplSink   = Nothing
set ReplServer = Nothing

© 1997-2000 Microsoft Corporation. All rights reserved.