🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: microsoft.public.win32.programmer.ole
7 messages
7 total messages Started by David Morgenlender Tue, 26 Jan 1999 00:00
Dynamic 2-dimensional array as parameter for COM method?
#7
Author: David Morgenlender
Date: Tue, 26 Jan 1999 00:00
15 lines
1497 bytes
I have to pass a 2-dimensional array as an input parameter to a COM method.
Neither dimension is known at compile time.  The interface is derived from
IUnknown.  The clients will be written in C++ & VB.  I already have dynamic
1-dimensional arrays working in both C++ & VB.  But I haven't been able to find
any way to specify a dynamic 2-dimensional array in the .IDL file.  I can, of
course, convert it to a 1-dimensional array as far as COM is concerned.  But I'd
rather keep it as 2-dimensional, if possible, to keep the code more readable,
etc.

Any ideas?

=======================================================
Dave Morgenlender
e-mail: dmorgen@alum.mit.edu
=======================================================
Re: Dynamic 2-dimensional array as parameter for COM method?
#8
Author: Jyrki Erjanti
Date: Wed, 27 Jan 1999 00:00
25 lines
1835 bytes
David Morgenlender wrote:
> 
> I have to pass a 2-dimensional array as an input parameter to a COM method.
> Neither dimension is known at compile time.  The interface is derived from
> IUnknown.  The clients will be written in C++ & VB.  I already have dynamic
> 1-dimensional arrays working in both C++ & VB.  But I haven't been able to find
> any way to specify a dynamic 2-dimensional array in the .IDL file.  I can, of
> course, convert it to a 1-dimensional array as far as COM is concerned.  But I'd
> rather keep it as 2-dimensional, if possible, to keep the code more readable,
> etc.
> 
> Any ideas?
> 
> =======================================================
> Dave Morgenlender
> e-mail: dmorgen@alum.mit.edu
> =======================================================

In IDL specify just VARIANT.

Use VARIANT of type VT_ARRAY | VT_xxx. Make parray of the
VARIANT to point to a SAFEARRAY. SAFEARRAY may contain
more than one dimension.

                 JE
Re: Dynamic 2-dimensional array as parameter for COM method?
#9
Author: Girish Bharadwaj [mvp]
Date: Wed, 27 Jan 1999 00:00
34 lines
2016 bytes
You can use size_is and pointer magic to represent what you want. But, I am
not sure about VB being happy about that..:-(
Something like
HRESULT Foo([out]int * size1, [out]int* size2,[out,size_is(,*size1,*size2)]
int *** arrayOfInts);
might work.. Here you are representing pointer to
arrayOfInts[*size1][*size2].. (I think ??)


--
Girish Bharadwaj [VC++/MVP].
Please Dont send email queries to me .Post them on the newsgroups.
Thank you

David Morgenlender wrote in message <36b2516d.85013812@enews.newsguy.com>...
>I have to pass a 2-dimensional array as an input parameter to a COM method.
>Neither dimension is known at compile time.  The interface is derived from
>IUnknown.  The clients will be written in C++ & VB.  I already have dynamic
>1-dimensional arrays working in both C++ & VB.  But I haven't been able to
find
>any way to specify a dynamic 2-dimensional array in the .IDL file.  I can,
of
>course, convert it to a 1-dimensional array as far as COM is concerned.
But I'd
>rather keep it as 2-dimensional, if possible, to keep the code more
readable,
>etc.
>
>Any ideas?
>
>=======================================================
>Dave Morgenlender
>e-mail: dmorgen@alum.mit.edu
>=======================================================
Re: Dynamic 2-dimensional array as parameter for COM method?
#10
Author: David Morgenlender
Date: Wed, 27 Jan 1999 00:00
17 lines
1462 bytes
Girish,

>You can use size_is and pointer magic to represent what you want. But, I am
>not sure about VB being happy about that..:-(
>Something like
>HRESULT Foo([out]int * size1, [out]int* size2,[out,size_is(,*size1,*size2)]
>int *** arrayOfInts);
>might work.. Here you are representing pointer to
>arrayOfInts[*size1][*size2].. (I think ??)

Thanks.  I'll give it a try, including with VB.  Now why didn't I think of that
syntax <g>!

=======================================================
Dave Morgenlender
e-mail: dmorgen@alum.mit.edu
=======================================================
Re: Dynamic 2-dimensional array as parameter for COM method?
#11
Author: David Morgenlender
Date: Wed, 27 Jan 1999 00:00
18 lines
1575 bytes
Jyrki,

>In IDL specify just VARIANT.
>
>Use VARIANT of type VT_ARRAY | VT_xxx. Make parray of the
>VARIANT to point to a SAFEARRAY. SAFEARRAY may contain
>more than one dimension.

Thanks for the suggestion.  I was hoping to avoid SAFEARRAY, because it's a pain
to use in C++.  Also, I vaguely recall running into some kind of compatibility
problem when I tried using it in the past, but I don't recall the details.
Maybe it's incompatible with an IUnknown interface.  But I might play around
with this, if I can't come up with something easier on the C++ side.

=======================================================
Dave Morgenlender
e-mail: dmorgen@alum.mit.edu
=======================================================
Re: Dynamic 2-dimensional array as parameter for COM method?
#12
Author: Alexander Nickolov
Date: Wed, 27 Jan 1999 00:00
34 lines
2014 bytes
I also would recommend safe arrays. VB is incapable of handling
C-style arrays. As for the C++ side - you have only to write two
convertor methods between your array class and safe array...

--
===============================
Alexander Nickolov
STL Panasonic
email: agnickolov@geocities.com
===============================

David Morgenlender wrote in message
<36ba2e2a.141530911@enews.newsguy.com>...
>Jyrki,
>
>>In IDL specify just VARIANT.
>>
>>Use VARIANT of type VT_ARRAY | VT_xxx. Make parray of the
>>VARIANT to point to a SAFEARRAY. SAFEARRAY may contain
>>more than one dimension.
>
>Thanks for the suggestion.  I was hoping to avoid SAFEARRAY, because it's a
pain
>to use in C++.  Also, I vaguely recall running into some kind of
compatibility
>problem when I tried using it in the past, but I don't recall the details.
>Maybe it's incompatible with an IUnknown interface.  But I might play
around
>with this, if I can't come up with something easier on the C++ side.
>
>=======================================================
>Dave Morgenlender
>e-mail: dmorgen@alum.mit.edu
>=======================================================
Re: Dynamic 2-dimensional array as parameter for COM method?
#13
Author: David Morgenlender
Date: Wed, 27 Jan 1999 00:00
13 lines
1462 bytes
"Alexander Nickolov" <agnickolov@geocities.com> wrote:

>I also would recommend safe arrays. VB is incapable of handling
>C-style arrays. As for the C++ side - you have only to write two
>convertor methods between your array class and safe array...

Actually, VB5 *IS* capable of handling C-style arrays, although it's not
documented.  I've had it working for awhile.

=======================================================
Dave Morgenlender
e-mail: dmorgen@alum.mit.edu
=======================================================
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads