Figure 4   Tracking Component Events

Event
Description
MTS Disable Commit
DisableCommit has been called on an object.
MTS Enable Commit
EnableCommit has been called on an object.
MTS Set Complete
SetComplete has been called on an object, and the object is now ready to be deactivated by MTS.
MTS Transaction Aborted
A transaction has aborted.
MTS Transaction Prepared
A transaction is preparing to commit, but has not actually committed yet.
MTS Transaction Start
Indicates that a transactional component has been created.
Object Create
Indicates that an object with context has been created.
Object Release
Indicates that an object has been released by MTS.


Figure 5 Tracking ADO Events

Event
Description
ConnectionClose
ADO is disconnecting from an OLE DB data source.
ConnectionOpen
ADO is connecting to an OLE DB data source.
Find
ADO client has called the ADO Recordset.Find function.
GetRows
ADO client has called the ADO Recordset.GetRows function.
QueryResult
Database has returned a resultset in response to a query.
QuerySend
ADO is executing a command. This event can be triggered by the following functions: Connection.Execute, Command.Execute, Connection.stored procedure name, Recordset.Open.


Figure 6   Registering a Component


 Option Explicit
 Private mInstall As Object
 
 ' This sub-routine just instantiated the Installer object.
 Private Sub MIND_InstantiateInstall()
    Set mInstall = New MSVSAEventSourceInstaller
 End Sub
 
 
 ' This sub-routine registers a COM component with Analyzer
 Private Sub MIND_RegisterCOMComponentSource()
    Dim sCOMComponentSourceGUID As String
    Dim sCOMComponentSourceName As String
    Dim sCOMComponentSourceDescr As String
    Dim sCLSID As String
    Dim lInProc As Long
    ' Add a unique GUID using GuidGen.exe.
    sCOMComponentSourceGUID = "{6F9A9124-E556-11d2-90FF-0080C76205C0}"
    ' Give your COM component a meaningful name
    sCOMComponentSourceName = "MIND Analyzer sample component"
    sCOMComponentSourceDescr =
      "Calculates current account charges and writes to the database. "
    ' Look up the component CLSID in the registry, and provide it as a value for 
    ' Analyzer to instantiate automoically
    sCLSID = "{D80FA506-4D5D-11D1-8B34-00C04FB90D09}"
    
    ' I want the COM component start in-proc so I use a true value 
    lInProc = 1
    ' Then I call the method
    mInstall.RegisterCOMComponentSourceSource _
        sCOMComponentSourceeGUID, _
        sCOMComponentSourceName, _
        sCOMComponentSourceDescr, _
        sCLSID, _
        lInProc
 End Sub

Figure 7   Registering MyEvent


 ' Register a user-defined (custom) event.
 Private Sub MIND_RegisterMyEvent(ByVal sSourceGUID As String)
    Dim sMyEventGUID As String
    Dim sMyEventName As String
    Dim sMyEventDescr As String
    Dim sIconFile As String, lIcon As Long
    ' sSourceGUID is the GUID for the source omponent
    
 ‘ Use the default all event category when grouping the event into a category
 Dim sDEBUG_EVENT_CATEGORY_ALL As String
 ‘ Use the default event to Event Call to set this up
    Dim sDEBUG_EVENT_TYPE_DEFAULT As String
     sDEBUG_EVENT_CATEGORY_ALL -
       "{6c736d86-BCBF-11D0-8A23-00AA00B58E10}  [Parent = _ALL]"
 sDEBUG_EVENT_TYPE_DEFAULT = "{6c736d62-BCBF-11D0-8A23-00AA00B58E10}"
      sSourceGUID = "{6F9A9121-E556-11d2-90FF-0080C76205C0}"
    ' Generate another unique GUID
       sMyEventGUID = "{6F9A9122-E556-11d2-90FF-0080C76205C0}"
    ' Assign a logical name and description to the event
    sMyEventName = "MINDSampleCustomDebugEvent"
    sMyEventDescr = "This is a test custom event."
    ' Pass the next two parameters empty.
    sIconFile = "": lIcon = 0
 
 ' This call assigns the defaults for event type and category.
    mESI.RegisterMyEvent _
        sSourceGUID, _
        sMyEventGUID, _
        sMyEventName, _
        sMyEventDescr, _
        sDEBUG_EVENT_TYPE_DEFAULT, sDEBUG_EVENT_CATEGORY_ALL, _
        sIconFile, _
        lIcon
 End Sub

Figure 8   Generating an Event


 ' Pass in the GUID of the event registered
 Private Sub MIND_FireEvent(ByVal sEventGUID As String)
    Dim Keys(1 To 3) As Variant, Values(1 To 3) As Variant
    Dim lCount As Long
    Dim lFlags As Long
    sEventGUID = "{6F9A9122-E556-11d2-90FF-0080C76205C0}"
    ' Provide as much information as you can in the parameters to the   
    ‘ event. You can also create arrays of keys and values for passing the  
    ‘ event parameters.
           Keys(1) = "Goner"   
    Values(1) = "Source machine"
    Keys(2) = "Stallion"      
    Values(2) = "Target Machine"
    Keys(3) = "Component interaction"     
    Values(3) = 2
    lCount = 3
    lFlags = cVSAEventStandard
  mEventInstaller.FireEvent sEventGUID, Keys, Values, lCount, lFlags
 End Sub