LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

CA_CStringToBSTR error

HRESULT CVIFUNC OpenSession (CAObjHandle objectHandle,
                                                  ERRORINFO *errorInfo,
                                                  const char *baseDir)
{
 HRESULT __result = S_OK;
 CableEyeCtl_ICableEye_Interface * __vtblIFacePtr = 0;
 int __didAddRef;
 int __errorInfoPresent = 0;
 BSTR baseDir__AutoType = 0;
           __caErrChk (CA_CStringToBSTR (baseDir, &baseDir__AutoType));

 __caErrChk (CA_GetInterfaceFromObjHandle (objectHandle,
                                           &CableEyeCtl_IID_ICableEye, 0,
                                           &__vtblIFacePtr, &__didAddRef));
 __caErrChk (__vtblIFacePtr->lpVtbl->OpenSession_ (__vtblIFacePtr,
                                                   baseDir__AutoType));

Error:
 CA_FreeBSTR (baseDir__AutoType);
 if (__vtblIFacePtr && __didAddRef)
  __vtblIFacePtr->lpVtbl->Release (__vtblIFacePtr);
 CA_FillErrorInfoEx (objectHandle, &CableEyeCtl_IID_ICableEye, __result,
                     errorInfo, &__errorInfoPresent);
 if (__errorInfoPresent)
  __result = DISP_E_EXCEPTION;
 return __result;
}

 

I am trying to use the above, however I keep getting errors using  __caErrChk (CA_CStringToBSTR (baseDir, &baseDir__AutoType));

This is due to the CA_CStringToBSTR function returning No size info  which inturn gives  a -ve return value.

 

I have tried to use CA_CStringToBSTR ("string", &baseDir__AutoType)  --  It does the same

 

What am I doing incorrectly, please help

0 Kudos
Message 1 of 4
(2,991 Views)

Hi Slten,

 

Please can you use the function below to convert the error you are getting from the HRESULT function into a meaningful error code.

 

http://zone.ni.com/reference/en-XX/help/370051V-01/cvi/libref/cvica_getautomationerrorstring/

 

 

Please post this here so I can then investigate this further. Any addition information such as which version of CVI you are using would also be useful.

 

Many thanks,

Josh E
Applications Engineer
National Instruments UK & Ireland
0 Kudos
Message 2 of 4
(2,958 Views)

Thank you for the reply

HR= CA_CStringToBSTR ("string", &baseDir__AutoType);

This does give a HR= 0  seems to return no size info..though

 

The issue with my post has been resolved.  I used create Activex Controller instead or create ActiveX Server

0 Kudos
Message 3 of 4
(2,944 Views)

Ok, thanks for letting me know!

Josh E
Applications Engineer
National Instruments UK & Ireland
0 Kudos
Message 4 of 4
(2,926 Views)