Admin Production ni-theme
Current Publication

CA_ServerAggregateObject

LabWindows/CVI

CA_ServerAggregateObject

HRESULT CA_ServerAggregateObject (CAServerObjHandle serverObjectHandle, const IID *interfaceIdToAggregate, IUnknown *innerObjectIUnknown);

Purpose

Aggregates another object's interface in the object whose handle is passed in the first parameter.

Note   Call this function only when the aggregating object (the outer object) is being created, that is, only in response to the CA_SERVER_EVENT_OBJECT_CREATE event in the aggregating object's callback function.

Example Code

The following code demonstrates aggregation.

HRESULT CVIFUNC OuterObjCb (CAServerObjHandle objHandle, const CLSID *pClsid, int event, void *callbackData)
{
   HRESULT hr = S_OK;
   IUnknown *pUnkAgg = NULL;
   IUnknown *pUnk = NULL;

   if (event == CA_SERVER_EVENT_OBJECT_CREATE) {
      caErrChk (CA_ServerGetIfaceFromObjHandle (objHandle,&IID_IUnknown,&pUnk));
      caErrChk (CA_ServerCreateObject (&CLSID_InnerObj, pUnk,&IID_IUnknown,&pUnkAgg));
      caErrChk (CA_ServerAggregateObject (objHandle,&IID_IAggregatedIface,pUnkAgg));
   }
Error:
   if (pUnk)
      pUnk->lpVtbl->Release (pUnk);
   if (pUnkAgg)
      pUnkAgg->lpVtbl->Release (pUnkAgg);
   return hr;
}

Parameters

Input
Name Type Description
serverObjectHandle CAServerObjHandle The handle to an ActiveX object in your ActiveX server.
interfaceIdToAggregate const IID * The interface Id to aggregate in this object.
innerObjectIUnknown IUnknown * The IUnknown pointer of the object whose interface is being aggregated.

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