Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SAFEARRAY ease of use

23 views
Skip to first unread message

Benjamin Pratt

unread,
May 15, 2008, 5:18:51 PM5/15/08
to
I regularly use a COM server that usually I use the normal COM interfaces
for. (CoCreate..., QueryInterface, etc)
These interfaces have a lot of array parameters.

I decided to import the TLB and try using the Automation interface, with the
idea that it would be simpler.

Now I have to pass array parameters as SAFEARRAYS. These SAFEARRAYS are
terribly unwieldly!
Is there a class that encapsulates SAFEARRAY usage, or am I stuck with
SafeArrayCreate, SafeArrayPutElement, SafeArrayDestroy?


Remy Lebeau (TeamB)

unread,
May 15, 2008, 9:17:17 PM5/15/08
to

"Benjamin Pratt" <a@b.c> wrote in message
news:482c...@newsgroups.borland.com...

> I regularly use a COM server that usually I use the normal COM
> interfaces for. (CoCreate..., QueryInterface, etc)
> These interfaces have a lot of array parameters.

Raw arrays are not safe to use in COM.

> Now I have to pass array parameters as SAFEARRAYS.

That is the only way to use arrays in COM. Hense the name *SAFE*ARRAY, aka
an "Automation-safe array".

> These SAFEARRAYS are terribly unwieldly!

Not really.

> Is there a class that encapsulates SAFEARRAY usage

Look at the VCL's safearry.h header file.


Gambit


Leif Suonvieri

unread,
Jul 31, 2008, 9:00:25 AM7/31/08
to
Benjamin Pratt skrev:

see this article for some good examples:

http://dn.codegear.com/article/22016

Leif Suonvieri

unread,
Jul 31, 2008, 9:01:24 AM7/31/08
to
Benjamin Pratt skrev:
see http://dn.codegear.com/article/22016
for some good expanations and some sample code
0 new messages