Adding one array as element of SafeArray. 
Author Message
 Adding one array as element of SafeArray.

What is the difference between SafearryAccessdata and
safearryputelement.

I have created a safearray with three element. First
element is passing Long. Second element is an another
safearry which also having 3 long elements.
Third element is another long variable.

Everything is added using safearryputelement function.

But while accessing the value i am not getting any values
of inner safearray.

I have attached the code here. Please if i am wrong give
your suggestion

  Samplecode.cpp
2K Download


Tue, 30 Nov 2004 17:11:51 GMT  
 Adding one array as element of SafeArray.
I think, we made this putting the inner SafeArray into an VARIANT, and than
the VARIANT in the outer SafeArray.
Uli



Quote:
> What is the difference between SafearryAccessdata and
> safearryputelement.

> I have created a safearray with three element. First
> element is passing Long. Second element is an another
> safearry which also having 3 long elements.
> Third element is another long variable.

> Everything is added using safearryputelement function.

> But while accessing the value i am not getting any values
> of inner safearray.

> I have attached the code here. Please if i am wrong give
> your suggestion



Tue, 30 Nov 2004 17:23:50 GMT  
 Adding one array as element of SafeArray.
After changing the type as variant in inner array, i am
not getting the values.

Quote:
>-----Original Message-----
>I think, we made this putting the inner SafeArray into an
VARIANT, and than
>the VARIANT in the outer SafeArray.
>Uli


Newsbeitrag

>> What is the difference between SafearryAccessdata and
>> safearryputelement.

>> I have created a safearray with three element. First
>> element is passing Long. Second element is an another
>> safearry which also having 3 long elements.
>> Third element is another long variable.

>> Everything is added using safearryputelement function.

>> But while accessing the value i am not getting any
values
>> of inner safearray.

>> I have attached the code here. Please if i am wrong give
>> your suggestion

>.



Tue, 30 Nov 2004 18:44:50 GMT  
 Adding one array as element of SafeArray.
Maybe Im not too clear. We are putting the inner array into an VARIANT, not
changing the VT of the inner array.
Uli



Quote:
> After changing the type as variant in inner array, i am
> not getting the values.

> >-----Original Message-----
> >I think, we made this putting the inner SafeArray into an
> VARIANT, and than
> >the VARIANT in the outer SafeArray.
> >Uli


> Newsbeitrag

> >> What is the difference between SafearryAccessdata and
> >> safearryputelement.

> >> I have created a safearray with three element. First
> >> element is passing Long. Second element is an another
> >> safearry which also having 3 long elements.
> >> Third element is another long variable.

> >> Everything is added using safearryputelement function.

> >> But while accessing the value i am not getting any
> values
> >> of inner safearray.

> >> I have attached the code here. Please if i am wrong give
> >> your suggestion

> >.



Tue, 30 Nov 2004 19:21:47 GMT  
 Adding one array as element of SafeArray.
1) You have created inner array as an array of VT_I4. So,
SafeArrayPutElement expects a pointer to long, not a pointer to variant:

for (long index = 0; index < 3; ++index)
    SafeArrayPutElement(pChargeSeq, &index, &index);

2) You make the same mistake when accessing the inner array. It is an
array of long, not of variant:

long *pInner;
 SafeArrayAccessData(pSaary,(void**)&pInner);
long a = pInner[0]; // pInner[1], pInner[2]

3) In the very last loop, you explicitly do not call SafeArrayGetElement
when lbound==1, but then somehow expect it to contain some value. In
addition, SafeArrayGetElement will not work while an array is locked.
You lock it when you call SafeArrayAccessData, and unlock with
SafeArrayUnaccessData.
--
With best wishes,
    Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken


Quote:
> What is the difference between SafearryAccessdata and
> safearryputelement.

> I have created a safearray with three element. First
> element is passing Long. Second element is an another
> safearry which also having 3 long elements.
> Third element is another long variable.

> Everything is added using safearryputelement function.

> But while accessing the value i am not getting any values
> of inner safearray.

> I have attached the code here. Please if i am wrong give
> your suggestion



Wed, 01 Dec 2004 00:44:52 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Why is only ONE element added?

2. use of one-element arrays?

3. delete one element in an array

4. Problem: array must have at least one element - what is wrong

5. Adding new elements to array class instance?

6. Adding Element To An Array

7. making pointers to structure elements using array elements

8. Acces the 11th element of a 10 element array

9. checkout compilers (Was: Acces the 11th element of a 10 element array)

10. Freeing a BSTR when using SafeArray{Get|Put}Element

11. Retrieving Safearray elements

12. SAFEARRAY (Variant) removing an element??

 

 
Powered by phpBB® Forum Software