Implementing an OnDelete Event Sink

Topic Last Modified: 2006-06-12

The following code receives the OnDelete event and returns information about it. See Store Event Sink Bit Flags for more information.

Example

Visual Basic

Private Sub IExStoreAsyncEvents_OnDelete(ByVal pEventInfo As Exoledb.IExStoreEventInfo, ByVal bstrURLItem As String, ByVal lFlags As Long)

    Dim FSO         As Object
    Dim EvtLog      As String
    Dim EvtFile

'log file
    EvtLog = Environ("SystemDrive") & "\OnDelete.log"

'Creates new log file %SystemDrive%\OnDelete.log or opens it if exists
    Set FSO = CreateObject("Scripting.FileSystemObject")
    Set EvtFile = FSO.OpenTextFile(EvtLog, 8, True)

'Append incoming event info into log file
    EvtFile.WriteLine ("[VB Event Sink]          OnDelete()")
    EvtFile.WriteLine ("  URL Item:              " & bstrURLItem)
    EvtFile.WriteLine ("  lFlags:                " & "0x" & Hex(lFlags))

'To determine type of OnDelete

    'Case 1: EVT_SOFTDELETE
    If lFlags And EVT_SOFTDELETE Then
        'Perform your tasks
        EvtFile.WriteLine ("  Flag contains EVT_SOFTDELETE bit set")
    End If

    'Case 2: EVT_HARDDELETE
    If lFlags And EVT_HARDDELETE Then
        'Perform your tasks
        EvtFile.WriteLine ("  Flag contains EVT_HARDDELETE bit set")
    End If

    'Check if it is a folder notification
    If lFlags And EVT_IS_COLLECTION Then
        'Perform your tasks
        'OnDelete for a folder
        EvtFile.WriteLine ("  Flag contains EVT_IS_COLLECTION bit set")
    End If

    EvtFile.WriteBlankLines (1)

'Before Quit
    EvtFile.Close
    Set FSO = Nothing

End Sub