LabWindows/CVI

Content Type
Programming Language
Current manual
Table of Contents

CA_LoadObjectFromFileByProgIdEx

CA_LoadObjectFromFileByProgIdEx

HRESULT CA_LoadObjectFromFileByProgIdEx (const char *filename, const char *progId, const char *serverMachineName, const IID *interfaceId, int supportMultithreading, LCID locale, intptr_t reserved, CAObjHandle *objectHandle);

Purpose

Creates an ActiveX server object and initializes it from a file.

The ActiveX server object is identified by the progId parameter. The initial data is contained in the file specified by the filename parameter.

You must call CA_InitActiveXThreadStyleForCurrentThread with COINIT_APARTMENTTHREADED if you register any ActiveX event callbacks and want the callbacks to be called from the same thread in which they were registered. If you do not call CA_InitActiveXThreadStyleForCurrentThread with COINIT_APARTMENTTHREADED, your callbacks will be called from a system thread.

Parameters

Input
Name Type Description
filename const char * A file containing the initial data for an ActiveX server object.
progId const char * The Prog Id of the ActiveX server object.
serverMachineName const char * The name or IP address of the machine on which you want to run the ActiveX server. The name can be either a UNC name ("\playdough") or DNS name ("plato.natinst.com").

If you pass NULL for this parameter and there is a ActivateAtStorage registry entry for this server, the server runs on the machine on which the file specified by the filename parameter resides.

If you pass NULL for this parameter and there is no ActivateAtStorage registry entry for this server, the server runs on the same machine as your program.
interfaceId const IID * The interface id specifying the type of the interface pointer that is associated with the objHandle.
supportMultithreading int Specify a nonzero value or select Yes in the function panel to use the object from multiple threads.

Specify 0 or select No in the function panel to use the object only from the thread that calls this function.

The ActiveX Library uses the COM Global Interface Table (GIT) to allow you to use an object handle from threads other than the thread in which it was created. There is overhead associated with using the GIT, which you should try to avoid when possible. If you do not pass the CAObjHandle between threads in your application, you do not need to use the GIT, and you can pass 0 for this parameter.

You do not need to use the GIT if all of the threads in which you use an object handle belong to the multithreaded apartment. You can call CA_InitActiveXThreadStyleForCurrentThread with COINIT_MULTITHREADED as the threading style. Refer to www.msdn.com for more information about threads and apartments.
locale LCID The locale you want to use. Usually, you should pass LOCALE_NEUTRAL, which signifies the default locale of the server. Refer to www.msdn.com for more information.
reserved intptr_t This parameter is reserved and must be zero.
Output
Name Type Description
objectHandle CAObjHandle A handle to the requested ActiveX object.

Use this handle to call methods or get and set properties of this ActiveX object.

When this handle is no longer needed, discard it by calling CA_DiscardObjHandle.

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

Was this information helpful?