COM
Expand Minimize

CoGetApartmentType function

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.

Windows Phone 8: This API is supported.

Windows Phone 8.1: This API is supported.

Requirements

Minimum supported client

Windows 7 [desktop apps | Windows Store apps]

Minimum supported server

Windows Server 2008 R2 [desktop apps | Windows Store apps]

Header

Objbase.h

Library

Ole32.lib

DLL

Ole32.dll

See also

APTTYPE
APTTYPEQUALIFIER

 

 

Community Additions

ADD
Show:
© 2014 Microsoft