Implement IObjectControl on your object. If you are running in an MTS package, IObjectControl::Activate and Deactivate will be called and you can set a switch. If you are not running in an MTS package, this will not be called unless you specifically call it, for exampleImplements ObjectControlPrivate m_bInMTS AS Boolean
Private m_ctxObject As ObjectContextPrivate Sub ObjectControl_Activate()
  Set m_ctxObject = GetObjectContext
  m_bInMTS = TRUE
End Sub Private Function ObjectControl_CanBePooled() As Boolean
  ObjectControl_CanBePooled = False
End FunctionPrivate Sub ObjectControl_Deactivate()
  Set m_ctxObject = Nothing
End Sub