SAFEARRAY parameters

From: Ed (splendided_at_aol.com)
Date: 03/05/04


Date: 5 Mar 2004 07:53:26 -0800

Hello

I'm stumped. Please forgive me this is more a COM proper than an ATL
question.

I have a Dispatch interface that exposes an interface method. (I'll
call this 'DI' as not to confuse myself). This interface method
accepts amongst other parameters a SAFEARRAY(VARIANT) * as well as an
IDispatch *.

Its usage involves another process which will invoke my COM Server an
pass an IDispatch * as well as a SAFEARRAY of Variants to my DI.

I marshal the Dispatch Pointer to a stream and make a copy of the
SAFEARRAY to a SAFEARRAY * within a data structure accessible to a
worker thread. You can see where this is heading.

My worker thread passes the Marshalled interface pointer and a pointer
to the SAFEARRAY * to another object which calls IDispatch::Invoke on
my marshalled interface. Before Invoking the method I reverse the
order of my parameters by using SafeArrayAccessData, swapping the
elements and unaccessing data.

Observation 1
=============

If I do not reverse the elements, only the first item in the array is
successfully passed to the IDispatch being invoked. Although the call
succeeds.

Observation 2
=============

If I reverse the elements for each call, the parameters will be passed
successfully for the first call and the same as in observation 1 for
the second call. This behaviour is cyclical 1 call OK, 1 call with 1
bad parameter.

The SAFEARRAY data does not change during the lifetime of the process.

Any help would be gratefully received!!

Many thanks in advance.

Regards

Ed



Relevant Pages

  • Re: theoretical question
    ... On 1 - add the attribute to your interface. ... it's as easy as having the client pull it. ... I want to get the acquired image into a safearray and fire an event ... the event handler to add to the queue. ...
    (microsoft.public.vc.atl)
  • Re: ATLs IDispatch implementation: no automatic SAFEARRAY -> VARIANT boxing?
    ... arrays with its clients using SAFEARRAY. ... It works nice with VB6 clients and VBA clients. ... I checked the interface type as "dual" .. ... expose both my "custom" interface ... ...
    (microsoft.public.vc.atl)
  • Re: SafeArrays problem between Fortran and VB .Net
    ... | End Interface ... By declaring that intData is an Integer, POINTER:: you tell the ... compiler to pass a SAFEARRAY**, ... | a method expecting an array of rank 1." ...
    (comp.lang.fortran)
  • Re: REPOST with Correct Address: SAFEARRAYs of interfaces other than IDispatch/IUnknown
    ... interface IProblemParameterGetter: IUnknown ... of the interfaces as this is the description in the safearray. ... you are marshaling the interface pointer that i ... type libraries that we'd like to provide implementations for in .NET. ...
    (microsoft.public.dotnet.framework.interop)
  • Re: SAFEARRAY parameters
    ... > I have a Dispatch interface that exposes an interface method. ... > pass an IDispatch * as well as a SAFEARRAY of Variants to my DI. ... you need to marshal every pointer individually ...
    (microsoft.public.vc.atl)