Admin Production ni-theme
Current Publication

CA_InitActiveXThreadStyleForCurrentThread

LabWindows/CVI

CA_InitActiveXThreadStyleForCurrentThread

HRESULT CA_InitActiveXThreadStyleForCurrentThread (void *reserved, unsigned int threadStyle);

Purpose

Sets the ActiveX threading style for a thread.

You must call this function with COINIT_APARTMENTTHREADED if you register any ActiveX event callbacks and want the callbacks to be called from the thread in which you register the callbacks. If you do not call this function with COINIT_APARTMENTTHREADED, your callbacks are called from a system thread.

If you call this function, you must call it before any other ActiveX Library function. All ActiveX Library functions initialize the thread to COINIT_MULTITHREADED if the thread has not already been initialized.

If you use this function to set the threading style of a thread to COINIT_MULTITHREADED, you will not be able to use ActiveX controls in that thread. If you need to use ActiveX controls you must initialize the thread to COINIT_APARTMENTTHREADED, or leave it uninitialized.

CA_InitActiveXThreadStyleForCurrentThread does not change the threading style for a thread if the threading style was already set.

CA_InitActiveXThreadStyleForCurrentThread calls the Windows SDK function CoInitializeEx.

Parameters

Input
Name Type Description
reserved void * This parameter is reserved and must be zero.
threadStyle unsigned int The ActiveX thread style for the current thread. Valid values are COINIT_MULTITHREADED and COINIT_APARTMENTTHREADED.

Return Value

Name Type Description
status HRESULT A value indicating whether an error occurred. Negative error codes indicate function failure.

Error codes are defined in CVIversion\include\cviauto.h and <Program Files>\National Instruments\Shared\MSDTRedistributables\SDKHeaderFiles\8.1\winerror.h. The LabWindows/CVI ActiveX Library explicitly returns error codes. Other error codes in winerror.h are generated by ActiveX servers and passed on to you by the LabWindows/CVI ActiveX Library.

You can use CA_GetAutomationErrorString to get the description of an error code or CA_DisplayErrorInfo to display the description of the error code.

Additional Information

Library: ActiveX Library

Include file: cviauto.h

LabWindows/CVI compatibility: LabWindows/CVI 5.5 and later