Create MTS components with VB6 (English, paste)

Source: Internet
Author: User
Tags exit
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



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.