Create ' casual stickers, learn VB people should know, sorry.
'**********************************************************************************************
' MTS VB6 COM Component template-by Michael Gonzalez
'**********************************************************************************************
' (1) must create a reference to the Microsoft Transaction Server Type Library (mtxas.dll).
' If using Windows watts, choose the COM + Services Library (comsvcs.dll) instead.
' (2) Set your classmodule ' s MTSTransactionMode property to 2-requirestransaction
' Note:only use 2-requires Transaction If you are using the component with a msdtc-
' compliant Resource Manager such as MSMQ or SQL server-otherwise, use
' 1-no transactions
' (3) Make sure your project ' s unattended Execution property is checked
' (4) Make sure your project ' Component Version compatibility are set to Binary compatibility
'**********************************************************************************************
' ObjectControl implements the interface ' is used by MTS ' the object is
' Activated and/or deactivated-this happens when you call one of the components ' s methods
' The ObjectControl implementation makes use of three procedures:
' 1) objectcontrol_activate
' 2) objectcontrol_canbepooled
' 3) objectcontrol_deactivate
'**********************************************************************************************
Implements ObjectControl
Dim Objoc as ObjectContext
Public Sub Something ()
' This is a user-defined procedure/method
' The ObjectContext Object is returned by GetObjectContext
On Error GoTo Abort
'*******************************************************
' Perform whatever you want
' Visual Basic 6 stuff goes here
' The Something () Procedure/method is just
' An example-you could use properties and
' Methods/procedures as well!
'*******************************************************
Finished:
Objoc.setcomplete
Exit Sub
Abort:
Objoc.setabort
Err.Raise Err.Number, Err.Source, Err.Description
Exit Sub
End Sub
Private Sub objectcontrol_activate ()
' MTS invokes this procedure/method the Component/object is instantiated
Set Objoc = GetObjectContext ()
Exit Sub
End Sub
Private Function objectcontrol_canbepooled () as Boolean
' This enables MTS object pooling (no currently supported my MTS 2.0)
objectcontrol_canbepooled = True
End Function
Private Sub objectcontrol_deactivate ()
' MTS invokes this procedure/method right before the Component/object is released
Set Objoc = Nothing
Exit Sub
End Sub