用VB6创建MTS组件


来源:   

随便贴贴,学过VB的人都应该知道的,不好意思。
'**********************************************************************************************
'                 MTS VB6 COM Component Template - by Michael Gonzalez
'**********************************************************************************************
'(1) You must create a reference to the Microsoft Transaction Server Type Library (mtxas.dll).
'    If using Windows 2000, 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 plan on using the component with an 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's Component Version Compatibility is set to Binary Compatibility
'**********************************************************************************************
'  ObjectControl implements the interface that is used by MTS when 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 in this area
    '       Visual Basic 6 stuff goes here
    '       The Something() procedure/method is just
    '       an example - you may use properties and other
    '       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 when the component/object is instantiated
    Set objOC = GetObjectContext()
    Exit Sub
End Sub

Private Function ObjectControl_CanBePooled() As Boolean
    'This enables MTS object pooling (not 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

编辑:

相关内容

 娱乐专题

more...

高峰私生子

王伯昭被打

傅彪肝癌晚期

赵薇餐馆打人事件

《云南映象》图集

张铁林拖欠中介费

女医生状告赵忠祥

高虎被捕事件

演绎经典美丽

解读《十面埋伏》

揭示明星美丽秘诀

五颜六色娱乐圈

明星纤体大比拼

《绿茶》精彩影评

天地英雄

吕丽萍群星艺术学校被起诉

于娜出道前被包养是真是假?

香港英皇贪污丑闻追踪

多少明星追忆中

2003环球小姐大赛

 

 叨叨专栏

more...

冯小刚,你怎么敢抽"上帝"?

流氓与流氓

娱乐媒体,请站直一点

原来张铁林不是中国人!

《神雕侠侣》的悲惨前途

男人,要硬派不要阴柔

请不要随便脱裤子

李欣,《自娱自乐》的挺滋儿!

不服没用,人家就是红了!

陆毅演戏吧,别唱歌了。

 

 

 
报业集团
- 版权声明 - 广告业务 - 联系方式
Copyright (C) 2001-2002 dzwww.com. All Rights Reserved
大众报业集团网络中心主办
Email:webmaster@mail.dzdaily.com.cn