From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing pointer to array to activex Method

Hello,
        I am having troubles, as evidently others have, passing a pointer to an array of bytes to an activeX method. I need to make a call and pass first a null pointer to the array and a pointer to an int.(Size). The size retured from that call would then be passed again in another call to the same maethod along with the pointer to the array and this then should return an array of data.
 
        I have seen the threads here about using the Labview.llb Moveblock call ..  I cant find labview.llb anywhere in my labview Version 8.0 installation so possibly it has a different name now or I just dont know where to look.
 
        I understand how to setup the pointer if I were using a Call Library Node but that is not an option for this activeX control as the paticular call I need to make is not exposed when I access it that way and I can only make the call using a method. 
 
        I can call this Activex component in Visual Basic passing the pointer and it all seems to work fine. It is a sad day I think when visual basic is easier to use than Labview but sadly that seems to be the case here.
 
        Your help would be most appreciated.
 
                 Louis
 
      
Message 1 of 6
(3,394 Views)

Louis,

Have you tried using a CIN function to for the Moveblock call??  Here are some LV 8.0 links related to your question that migh also help:

-MoveBlock (CIN Function)
-Connectivity VIs and Functions
-Memory Manager Functions
-Creating a CIN That Concatenates Two Strings

Best of luck!

Message 2 of 6
(3,370 Views)

You don't need to go to the CIN, because that is for straight C systems, not ActiveX. Like VB, LV uses the TypeLib to understand what methods are exposed by the component and provide automatic data mapping. If you can call this method from VB, I'm assuming that the array is actually a SafeArray type (an oleautomation type).

Go to the ActiveX palette and use the Automation Open to create the instance of the component. When you wire the resulting refnum to the ActiveX Invoke Node, you should be able to see the list of all the methods you can call, along with the mapping to LV types. Does this get you where you need, or did I miss the problem?

Message 3 of 6
(3,370 Views)

Mark and Brian,

     Thank both of you for taking time to reply. You have both been helpful. I am looking at setting up the CIN call and that may be what I need to do. In answer to your question Brian placed an ActiveX container on the page and then created a reference to that and the selected the method as you had indicated. I had done this before the problem is that the argument they are looking for is a pointer to an array of uint8. I can create that array and give init it to some size but when you try to pass that to the method it is looking for a u32 (pointer) not the [uint8] array that I have. Since there is no way to get the pointer to the array of uint8 in labview I am thinking that the CIN route may be what is needed.

      Possibly I am not understanding how what you are sugesting is different that what I am doing.

            In C this would be very simple,

                  long size = 0;

                  char *pBuf=NULL

                  m_pGrab->GetCurrentBuffer(&size, NULL);            // Null pointer flags it to return the buffer size

                  pBuf = new char[size]  ;                                           // allocate space for the data based upon the size returned

                  m_pGrab->GetCurrentBuffer(&size,(long*)pBuf);   // get the data from the buffer

          Basicaly that is it.

           In labview I have a reference to the ActiveX component.

                   I make a call to the Method GetCurrentBuffer and that has arguments pSize and pBuffer both Int32.

                       I pass a int32 (zero) to the pBuffer to request the buffer size. This should be the same as a Null

                       I pass the int32 size value which should be the pointer to the size not the value

                              ( I should get the size of the buffer returned but this does not work because size is not a porinter to the size but

                                            rather the size value)

                       If however  I were to get a returned size I would then use this to allocate the array for the return buffer data

                      I pass the size returned from the above call and the buffer value from the init array

                      this unfortunately does not work because the call is looking for and int32 (pointer) and not the [int32] that I get from

                       the array init.

                    Does all that make some sense?

 

                       Thanks , Louis

0 Kudos
Message 4 of 6
(3,352 Views)
Let me be a little more succinct.
 
            I have a method I am passing parameters into. These need to be
                   1. a pointer to an int32 Size
                   2. a pointer to and array of uint8
 
                   I have a size.. int32
                   I have a buffer array of uint8
 
                   so how do I pass the address of each to the method. It is that simple.
 
 
0 Kudos
Message 5 of 6
(3,350 Views)
Unfortunately, you can't get a pointer to the address of a LV datatype as you're asking - that is something we do for you automatically when the COM info tells us that's what we need to do. My guess at the problem here is that the TypeLib information for the COM object is not declaring the parameters fulling, using in/out and size_is. That is what LV uses in order to correctly generate the invoke nodes with input and output terminals. For example, I'd assume it'd need something like
 
void GetBufferBuffer([in,out] long *size,   [size_is(*size)] char* pBuf);
 
Can you post the TLB?
0 Kudos
Message 6 of 6
(3,319 Views)