DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Sat, 21 Jul 2007 18:43:44 -0700,    posted on: microsoft.public.dotnet.framework.interop        back       

Thread Index
  1    Brian Jones
          2    Brian Muth
          3    Jealani


Newbie COM question about passing arrays   
Hello,
I'm new to COM development. Here's what I want to do:

In unmanaged C++:

1) Create an interface called ITeam
2) Create another interface called IPerson
3) Create a method in ITeam called GetTeamMembers. this will return an array 
of IPerson's.

In unmanaged C# or VB.NET:

I want to call the above GetTeamMembers method, and process it using a 
foreach loop.

Hopefully this isn't too complicated. Can someone point me to any articles 
or sample code to do this, or just let me know some keywords I should search 
Google for? I don't know where to start for passing arrays in COM.

Thanks.

-Brian
Date:Sat, 21 Jul 2007 18:43:44 -0700   Author:  

Re: Newbie COM question about passing arrays   
"Brian Jones"  wrote in message 
news:%231qg%23GAzHHA.3696@TK2MSFTNGP03.phx.gbl...

> Hello,
> I'm new to COM development. Here's what I want to do:
>
> In unmanaged C++:
>
> 1) Create an interface called ITeam
> 2) Create another interface called IPerson
> 3) Create a method in ITeam called GetTeamMembers. this will return an 
> array of IPerson's.
>
> In unmanaged C# or VB.NET:
>
> I want to call the above GetTeamMembers method, and process it using a 
> foreach loop.
>
> Hopefully this isn't too complicated.


I'm afraid it's a little more complicated that you think.

In order to use the foreach construct, you need to build an interface that 
derives from IDispatch and implements
[id(DISPID_NEWENUM), propget] HRESULT _NewEnum([out, retval] IUnknown** 
ppEnum);

This returns an interface called a COM enumerator. A typical interface would 
be IEnumVariant, which can handle enumerating over a collection of variants.

Since you are posting in an ATL newsgroup, you might be interested in 
knowing that there are a number of useful ATL templates to help with the 
enumeration implementation, specifically CComEnumOnSTL and IEnumOnSTLImpl<>.

You might be able to Google for some examples, but the very best reference 
is Chapter 7 of the highly esteemed book ATL Internals. There are over 50 
pages dedicated to this subject (Collections and Enumerators), which I think 
reflects that fact that this is a little more complicated than what you are 
probably anticipating.

Brian
Date:Sat, 21 Jul 2007 22:08:58 -0700   Author:  

Re: Newbie COM question about passing arrays   
did you get an answer on how to pass arrays to COM component. if so
please let me know. i shall update you if i happen to find the
solution first. thank you.
Date:Fri, 03 Aug 2007 12:43:15 -0700   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us