Platform SDK: Transaction Server |
[This product will work only on Windows NT 4.0 versions and earlier. For Windows 2000 and later, see COM+ (Component Services).]
Instantiates an MTS object.
New applications should call createInstance.
Provided By
IUnknown CreateInstance ( _Guid clsid, _Guid iid, );
Parameter
clsid
[in] The clsid of the type of object to instantiate.
iid
[in] Any interface that's implemented by the object you want to instantiate.
Return Value
A reference to the IUnknown interface on the newly created object.
Remarks
CreateInstance creates a COM object. However, the object will have context only if its component is registered with MTS.
When you create an object by using CreateInstance, the new object's context is derived from the current object's ObjectContext and the declarative properties of the new object's component. The new object always executes within the same activity as the object that created it. If the current object has a transaction, the transaction attribute of the new object's component determines whether or not the new object will execute within the scope of that transaction.
If the component's transaction attribute is set to either Requires a transaction or Supports transactions, the new object inherits its creator's transaction. If the component's transaction attribute is set to Requires a new transaction, MTS initiates a new transaction for the new object. If the component's transaction attribute is set to Does not support transactions, the new object doesn't execute under any transaction.
CreateInstance always returns the IUnknown interface on the newly instantiated object. You should immediately cast the returned value to the interface through which you want to communicate with the new object. The interface ID you pass in the iid parameter doesn't have to be the same interface as the one to which you cast the returned value, but it must be an interface that's implemented by the object you're instantiating.
MTS always uses standard marshaling. Even if a component exposes the IMarshal interface, its IMarshal methods will never be called by the MTS run-time environment.
You can't create MTS objects as part of an aggregation.
See Also
Creating MTS Objects, Transaction Attributes, MTS Component Requirements