Compartilhar via


ITransactionOptions::GetOptions

 

Applies To: Windows 10, Windows 7, Windows 8, Windows 8.1, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2, Windows Server Technical Preview, Windows Vista

The GetOptions method is used to read transaction attributes from a transaction options object.

Syntax

  
HRESULT GetOptions(   XACTOPT * pOptions);  

Parameters

pOptions
[in, out] Reference to a XACTOPT structure containing attribute information for a transaction options object. The szDescription field must be pre-allocated with the correct length.

Return Values

S_OK
Success.

E_OUTOFMEMORY
Unable to allocate memory.

E_INVALIDARG
The value of pOptions is NULL.

Remarks

This method can used to determine the description and the transaction timeout of a transaction that is already in progress, as shown in the following sample code.

ITransactionDispenser * pTransactionDispenser;  
ITransaction * pTransaction;  
ITransactionOptions* pTxOpt;  
XACTOPT xopt;  
HRESULT hr = S_OK ;  
  
// Obtain a transaction dispenser interface pointer from the DTC.  
hr = DtcGetTransactionManager(NULL, NULL,   
                            IID_ITransactionDispenser, 0, 0,  
                  (void *)NULL, (void **)&pTransactionDispenser);  
if (FAILED (hr))   
{  
    printf("The DtcGetTransactionManager failed: Error # %#x\n", hr);  
    exit(1); // Replace with specific error handling.  
}  
  
hr = pTransactionDispenser->BeginTransaction( NULL,   
      ISOLATIONLEVEL_ISOLATED, ISOFLAG_RETAIN_DONTCARE,   
      NULL, &pTransaction);  
if (FAILED (hr))   
{  
    printf("BeginTransaction failed: Error # %#x\n", hr);  
    exit(1); // Replace with specific error handling.  
}  
  
hr = pTransaction->QueryInterface(IID_ITransactionOptions,  
                                    (void**)&pTxOpt);  
if (FAILED (hr))   
{  
    printf(  
        "QueryInterface for ITransactionOptions failed: Error # %#x\n",   
         hr);  
        exit(1); // Replace with specific error handling.  
}  
  
hr = pTxOpt->GetOptions(&xopt);  
if (FAILED (hr))   
{  
    printf("GetOptions failed: Error # %#x\n", hr);  
    exit(1); // Replace with specific error handling.  
}  
else  
{  
    printf("Description: %s\n", xopt.szDescription);  
    printf("Timeout: %d\n", xopt.ulTimeout);      
}  
  

Requirements

For an explanation of the requirement values, see Requirements (Component Services).

Platforms: Windows Server 2016, Windows 10, Windows Server 2012 R2, Windows 8.1, Windows Server 2012, Windows 8, Windows Server 2008 R2, Windows 7, Windows Server 2008, Windows Vista

Header: Declared in transact.h

See Also

ITransactionDispenser