LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview - reading an array from a com object

Hi!

I have constructed a com-object in visual c++. This object will just
return an array of variants. The method connected to the interface has
one out parameter that consists of a pointer to a variant. I dont know
how labview handles this type. It seems that it doesnt recognize the
type. It just gives the error message, "A null reference pointer was
passed through the stub"?!?! I have also written a com-client in c++
that communicates with this com-server. This one works fine! How does
labview handles arrays?! I have also tried to just return one "Variant
value" from the server. Same problem here, "A null....".#"¤%"%

com-server implementation:

STDMETHODIMP CTEEServices::TestVariant7(VARIANT inData, VARIANT

*pOutData)
{
VariantInit(pOutData);
LPVOID pvdata;
int *pElement;

pOutData->vt=VT_ARRAY;//Set VARIANT type to array
SAFEARRAYBOUND rgsabound[1];
rgsabound[0].lLbound=0;
rgsabound[0].cElements=10;//10 elements
pOutData->parray=SafeArrayCreate(VT_I4,1,rgsabound); //Create a
safearray in VARIANT
pvdata=pOutData->parray->pvData; //Get address to array
pElement=(int*)pvdata;

for(int i=0;i<10;i++) //Fill it up!
{
*pElement=i;
pElement+=1;
}

return S_OK;
}

regards,
Peter


Sent via Deja.com http://www.deja.com/
Before you buy.
0 Kudos
Message 1 of 2
(2,879 Views)
Hi

I'll send you an example of how I retreve a 2D array from an ActiveX control
in C++ an how it is wired in LV

Hans


wrote in message news:892sjt$c0i$1@nnrp1.deja.com...
> Hi!
>
> I have constructed a com-object in visual c++. This object will just
> return an array of variants. The method connected to the interface has
> one out parameter that consists of a pointer to a variant. I dont know
> how labview handles this type. It seems that it doesnt recognize the
> type. It just gives the error message, "A null reference pointer was
> passed through the stub"?!?! I have also written a com-client in c++
> that communicates with this com-server. This one works fine! How does
> labview handles arrays?! I have also tried to just return one "Var
iant
> value" from the server. Same problem here, "A null....".#"¤%"%
>
> com-server implementation:
>
> STDMETHODIMP CTEEServices::TestVariant7(VARIANT inData, VARIANT
> *pOutData)
> {
> VariantInit(pOutData);
> LPVOID pvdata;
> int *pElement;
>
> pOutData->vt=VT_ARRAY;//Set VARIANT type to array
> SAFEARRAYBOUND rgsabound[1];
> rgsabound[0].lLbound=0;
> rgsabound[0].cElements=10;//10 elements
> pOutData->parray=SafeArrayCreate(VT_I4,1,rgsabound); file://Create a
> safearray in VARIANT
> pvdata=pOutData->parray->pvData; file://Get address to array
> pElement=(int*)pvdata;
>
> for(int i=0;i<10;i++) file://Fill it up!
> {
> *pElement=i;
> pElement+=1;
> }
>
> return S_OK;
> }
>
> regards,
> Peter
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.



[Attachment C2 test.vi, see below]


[Attachment ActiveX.txt, see below]
Download All
0 Kudos
Message 2 of 2
(2,879 Views)