🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: microsoft.public.win32.programmer.ole
Article #4

Re: Dynamic 2-dimensional array as parameter for COM method?

#4
From: Randy Buckland
Date: Thu, 28 Jan 1999 00:00
53 lines
3229 bytes
Jyrki Erjanti <Jyrki.Erjanti@fidri.mail.abb.com> writes:

>David Morgenlender wrote:
>> 
>> Jyrki Erjanti <Jyrki.Erjanti@fidri.mail.abb.com> wrote:
>> 
>> >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.
>> 
>> Why is a VARIANT required, instead of specifying SAFEARRAY directly?
>> 
>> =======================================================
>> Dave Morgenlender
>> e-mail: dmorgen@alum.mit.edu
>> =======================================================


>You can use SAFEARRAY directly, but doing so may limit the
>use of your component. I have heard that there are many
>language implementations, which, although they claim to be
>"automation compatible", do not allow SAFEARRAYs to be
>used directly.

>Even VB 5.0 interpretes the "compatibility" so that it
>does not accept SAFEARRAY as [in] parameter but requires
>SAFEARRAY*.

>                      JE

And just to add another layer of complication, I just wrote some C++ code
that was called by ASP code and was passing arrays from ASP to C++.
ASP passed a VARIANT with type VT_VARAINT|VT_BYREF. Following the indirection,
I found another VARIANT with type VT_ARRAY|VT_BYREF. Following that byref
pointer, I finally found a SAFEARRAY* value that I could use. Yuck.

Of course I was trying to use something that looked and acted like an array
from the Request object originally (The form calling this page had multipl
input fields with the same name and you could get them with a call to
Request("Fieldname")(2) to get the second field.) I originally tried 
passing Request("Fieldname") to my C++ function but found out that this
pass a VT_VARIANT|VT_BYREF that pointed to a VT_DISPATCH object.
I had to declare an array of the proper size and copy the items into this
array and pass it to C++ to get the above layout. Yuck again.

VB Sucks!
--
Randy Buckland                                  "It's difficult to work
Independent computer consultant                  in a group when you're
rcb@nospam.ipass.net                             omnipotent"       -- Q
(Remove the "nospam." from the above address. Just say no to spam!)
Technical Details
Message-ID: <kfZr2.698$24.2152@news.ipass.net>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <36b2516d.85013812@enews.newsguy.com> <36AF44FA.3757@fidri.mail.abb.com> <36b3682b.13300621@enews.newsguy.com> <36B09C3C.63F4@fidri.mail.abb.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 108cda,d933c915558e7daf
X-Google-Attributes: gid108cda,public
X-Google-Thread: f9701,d933c915558e7daf
X-Google-Attributes: gidf9701,public
X-Google-Thread: fe15c,d933c915558e7daf
X-Google-Attributes: gidfe15c,public
From: rcb@nospam.ipass.net (Randy Buckland)
Subject: Re: Dynamic 2-dimensional array as parameter for COM method?
Date: 1999/01/28
Message-ID: <kfZr2.698$24.2152@news.ipass.net>
X-Deja-AN: 437918435
References: <36b2516d.85013812@enews.newsguy.com> <36AF44FA.3757@fidri.mail.abb.com> <36b3682b.13300621@enews.newsguy.com> <36B09C3C.63F4@fidri.mail.abb.com>
X-Complaints-To: abuse@ipass.net
X-Trace: news.ipass.net 917528656 198.79.53.10 (Thu, 28 Jan 1999 08:04:16 EDT)
Organization: iPass.Net
NNTP-Posting-Date: Thu, 28 Jan 1999 08:04:16 EDT
Newsgroups: microsoft.public.win32.programmer.ole,comp.os.ms-windows.programmer.ole,borland.public.cppbuilder.activex