LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass BSTR string from LV to COM automation method

Hi,
I need to pass from my VI module a  string to COM automation BSTR method formal parameter.
 
I tried to use a string array, with "Index Array ",  then  a simple string constant , a normal string control and so on.
In any case windows come up with a exception handler with this message in <Error Out>:
 
"Invalid access to memory location  in ACLAM.Execute.vi"
 
LABView  treats this type of data like a normal string, or I need  something like a pointer ?
Which type of conversion have to insert for resolve my problem ?
 
I attached, my VI  module containing the call   to    ::Execute(....) method of my COM.
 
<Execute>  code:
 
     STDMETHODIMP
     CACLAM::Execute(
               /*[in]          */  BSTR      Service,     <---------      FAIL   on IT !!! 
               /*[in,optional] */  VARIANT*  Params,
               /*[out,optional]*/  VARIANT*  Response,
               /*[out,retval]  */  BOOL*     RVal
               )
     {
          AFX_MANAGE_STATE(AfxGetStaticModuleState());
          *RVal = FALSE ; // assume failure
          TRACE( " * [ ACLAM.Execute:  Service-> %s ] *\n", (LPCTSTR)*Service ) ;
          try
          {
               {
                    LPCTSTR sSERVICE = gService.GetLPCTSTR( Service ) ;
                    if ( strcmp ( sSERVICE, "ErrorQuery" ) == 0 )
                    {
      
) ? S_OK : S_FALSE ) ; 

.......

........

Can You help me?

TIA.
 
Giando.
 
0 Kudos
Message 1 of 2
(2,754 Views)
I suggest you take a look at this example that's found on the ni.com/support website
 
 
It shows how to pass different types of data back and forth from LV to an ActiveX.

Regards,
AlessioD
 
0 Kudos
Message 2 of 2
(2,739 Views)