This topic has not yet been rated - Rate this topic

CoGetApartmentType function

Applies to: desktop apps | Metro style apps

Returns the current apartment type and type qualifier.

Syntax

HRESULT WINAPI CoGetApartmentType(
  __out  APTTYPE *pAptType,
  __out  APTTYPEQUALIFIER *pAptQualifier
);

Parameters

pAptType [out]

APTTYPE enumeration value that specifies the type of the current apartment.

pAptQualifier [out]

APTTYPEQUALIFIER enumeration value that specifies the type qualifier of the current apartment.

Return value

Returns S_OK if the call succeeded. Otherwise, one of the following error codes is returned.

Return codeDescription
E_FAIL

The call could not successfully query the current apartment type and type qualifier.

E_INVALIDARG

An invalid parameter value was supplied to the function. Specifically, one or both of the parameters were set to NULL by the caller.

CO_E_NOTINITIALIZED

CoInitialize or CoInitializeEx was not called on this thread prior to calling CoGetApartmentType.

 

Remarks

On Windows platforms prior to Windows 7, the following actions must be taken on a thread to query the apartment type:

In multithreaded scenarios, there is a race condition which can potentially cause an Access Violation within the process when executing the above sequence of operations. The CoGetApartmentType function is recommended as it does not potentially incur the Access Violation.

Requirements

Minimum supported client

Windows 7

Minimum supported server

Windows Server 2008 R2

Header

Objbase.h

Library

Ole32.lib

DLL

Ole32.dll

See also

APTTYPE
APTTYPEQUALIFIER

 

 

Send comments about this topic to Microsoft

Build date: 3/7/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ