Passing an array through the COM interface in ATL 
Author Message
 Passing an array through the COM interface in ATL

Hello,

I would like to passing an array through the COM
interface, but it does not succeed.

In my case, i have :
STDMETHODIMP ComCtrl::GetSelectedArray( /*[out]*/BSTR
*bstrVal){
CComBSTR combStr1= "test01";
CComBSTR combStr2= "test02";
CComBSTR combStr3= "test03";
*(bstrVal+0) = combStr1;
*(bstrVal+1) = combStr2;
*(bstrVal+2) = combStr3;
return 0;

Quote:
}

In another side:
BSTR bstVal[10];
GetSelectedArray(bstVal);

I have checked the result, the value of bstVal[0]~[2] are
all equal "test03"?

Why i cannot pass the array in such way ? Can someone show
me the true method to pass the array ?

Thank you
David



Tue, 05 Apr 2005 19:50:42 GMT  
 Passing an array through the COM interface in ATL

Quote:
> Hello,

> I would like to passing an array through the COM
> interface, but it does not succeed.

> In my case, i have :
> STDMETHODIMP ComCtrl::GetSelectedArray( /*[out]*/BSTR
> *bstrVal){
> CComBSTR combStr1= "test01";
> CComBSTR combStr2= "test02";
> CComBSTR combStr3= "test03";
> *(bstrVal+0) = combStr1;
> *(bstrVal+1) = combStr2;
> *(bstrVal+2) = combStr3;
> return 0;
> }

> In another side:
> BSTR bstVal[10];
> GetSelectedArray(bstVal);

> I have checked the result, the value of bstVal[0]~[2] are
> all equal "test03"?

> Why i cannot pass the array in such way ? Can someone show
> me the true method to pass the array ?

I think you need to use a safe array. Read about them here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dngu...
l/drgui042099.asp

HTH, Loz.



Tue, 05 Apr 2005 21:05:01 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. ATL COM - Passing ATL COM classes through another ATL COM class in the same app

2. COM/ATL novice:passing object pointers through methods on a COM interface

3. COM Interop - How to pass C# uint array to COM interface which takes UINT *pArray

4. Passing byte array from C# to C++ COM interface

5. Passing byte array from C# to C++ COM interface

6. Passing array from ATL COM to VBScript client

7. Passing Arrays Between VB and ATL COM object

8. Passing an integer array from Visual Basic to an ATL COM object function

9. ATL COM Passing other ATL classes through an ATL COM interface..

10. passing COM object pointers to another COM object in ATL

11. How to pass an array of array into a COM object

12. Pass an array of array into a COM object

 

 
Powered by phpBB® Forum Software