Admin Production ni-theme
Current Publication

CA_ServerGetIfaceFromObjHandle

LabWindows/CVI

CA_ServerGetIfaceFromObjHandle

HRESULT CA_ServerGetIfaceFromObjHandle (CAServerObjHandle serverObjectHandle, const IID *interfaceId, void *interfacePtr);

Purpose

Gets an interface pointer from the object whose handle is passed in the first parameter.

Typically this function is used to obtain interface pointers that are returned to ActiveX Clients requesting them.

Parameters

Input
Name Type Description
serverObjectHandle CAServerObjHandle The handle to an ActiveX object in your ActiveX server.
interfaceId const IID * The interface id of the interface requested from the object.
Output
Name Type Description
interfacePtr void * The interface pointer (of the type passed in the interfaceId parameter) obtained from your ActiveX object. If your ActiveX object does not implement this type of interface, then this parameter is set to NULL.

Pass the address of an interface pointer variable of the required interface type. Typically this interface pointer is returned to ActiveX clients requesting them. If these interface pointers need to be disposed (and not returned to the ActiveX clients), call the Release method on the interface pointer as follows:

IFoo *pIFoo = NULL;
CA_ServerGetIfaceFromObjHandle (objHandle, IID_IFoo, (void**)&pIFoo);
// Some failure occurs elsewhere, so have to release pIFoo
if (pIFoo) {

pIFoo->lpVtbl->Release (pIFoo);

pIFoo = NULL;

}

Return Value

Name Type Description
status HRESULT A value indicating whether an error occurred. Function failure is indicated by a negative error code.

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 the COM runtime and passed on to you by the 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.

Note   You should not return the ActiveX Library error codes from your ActiveX server to your ActiveX clients, unless you document them in your server documentation. An acceptable compromise in this case is to return E_UNEXPECTED to the clients.

The error codes defined in <Program Files>\National Instruments\Shared\MSDTRedistributables\SDKHeaderFiles\8.1\winerror.h are too numerous to display here. These error codes can be returned to your ActiveX clients.

Additional Information

Library: ActiveX Library

Include file: cviauto.h

LabWindows/CVI compatibility: LabWindows/CVI 6.0 and later