欢迎光临
我们一直在努力

用VB6创建MTS组件(英,转贴)

建站超值云服务器,限时71元/月

随便贴贴,学过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 classmodules 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 projects unattended execution property is checked
(4) make sure your projects 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 componentss 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

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 用VB6创建MTS组件(英,转贴)
分享到: 更多 (0)