Accessing string elements in a _variant_t array 
Author Message
 Accessing string elements in a _variant_t array

Hello

I have a client COM program which invokes a function, GetDevicesArray()
which returns an array of strings:

 _variant_t vArr = pCuba->GetDevicesArray();

 long eles = vArr.parray->rgsabound->cElements;

I know I get the correct array back because eles - num elements is correct.

But how do I access the string array elements?

Angus Comber



Thu, 09 Sep 2004 20:50:48 GMT  
 Accessing string elements in a _variant_t array
SafeArrayGetElement(vArr.pArray, iElement, &bsValue) works for me --
remember to SysFreeString(bsValue) when you're done with it.

Note that you should call SafeArrayGetLBound/SafeArrayGetUBound to get the
range of array indexes -- the array doesn't have to start with 0.


Quote:
> Hello

> I have a client COM program which invokes a function, GetDevicesArray()
> which returns an array of strings:

>  _variant_t vArr = pCuba->GetDevicesArray();

>  long eles = vArr.parray->rgsabound->cElements;

> I know I get the correct array back because eles - num elements is
correct.

> But how do I access the string array elements?

> Angus Comber




Thu, 09 Sep 2004 22:05:26 GMT  
 Accessing string elements in a _variant_t array
See also SafeArrayAccessData and SafeArrayUnaccessData.
--
With best wishes,
    Igor Tandetnik

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


Quote:
> Hello

> I have a client COM program which invokes a function,
GetDevicesArray()
> which returns an array of strings:

>  _variant_t vArr = pCuba->GetDevicesArray();

>  long eles = vArr.parray->rgsabound->cElements;

> I know I get the correct array back because eles - num elements is
correct.

> But how do I access the string array elements?

> Angus Comber




Sat, 11 Sep 2004 01:22:54 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Time for accessing array elements - linear or constant ?

2. How to access and assign to elements in an array

3. jscript array element access in c++

4. A question about char *array[] element access?

5. Copying a string to an array element

6. breaking up string into array elements

7. copying elements from argv[] to array of strings ?

8. making pointers to structure elements using array elements

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

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

11. pointers to an array and accesing elements of the array

12. How to trim a string in a _variant_t

 

 
Powered by phpBB® Forum Software