[DUG] Returning a WideString in an Invoke Param

Conor Boyd Conor.Boyd at trimble.co.nz
Tue Jul 18 12:05:35 NZST 2006


Okay, even if it's a record, I think you're still going to have to look
at turning that record into an OleVariant (as we talked about a few
weeks back IIRC) for transporting between server and client. 

-----Original Message-----
From: delphi-bounces at ns3.123.co.nz [mailto:delphi-bounces at ns3.123.co.nz]
On Behalf Of Phil Middlemiss

The Invoke method is the only way of handling the IDispInterface events.
The Automation wizard automatically generates the Invoke stub and leaves
it up to the programmer to fill it in. The code works fine when I'm just
passing integer values etc, but this is the first time I've needed to
use a VAR parameter in an IDispInterface event.

The TDispParams is a record (tagDISPPARAMS) in ActiveX.pas.

Conor Boyd wrote:
> I just use WideStrings in COM parameters without any conversions at 
> all in D7 and BDS2006.
>
> However, is TDispParams a class?
>
> Surely you'll have to do some sort of streaming for the TDispParams 
> type?
>
> -----Original Message-----
> From: delphi-bounces at ns3.123.co.nz 
> [mailto:delphi-bounces at ns3.123.co.nz]
> On Behalf Of Phil Middlemiss
>
> I have an automation object with events. One of the events has a 
> couple of VAR parameters which I'm not quite sure how to handle. Here 
> is the code that is NOT working:
>
> procedure TT3SDKEvents.DoInvoke(Sender : TObject; DispID: Integer; 
> const
> IID: TGUID;
>   LocaleID: Integer; Flags: Word; var Params: TDispParams; VarResult, 
> ExcepInfo,
>   ArgErr: Pointer);
>     case DispID of
>
>     ...
>
>     4: { OnIdentify }
>       if assigned(FOnIdentify) then
>         begin
>         //initialise the values
>         layermanagerid :=  WideCharToString(Params.rgvarg[1].bStrVal);
>         appname := WideCharToString(Params.rgvarg[0].bstrVal);
>         if assigned(FOnIdentify) then
>           FOnIdentify(layermanagerid, appname);
>         Params.rgvarg[1].bstrVal := PWideChar(layermanagerid);
>         Params.rgvarg[0].bstrVal := PWideChar(appname);
>         end;
>     end;
> end;
>
> The above code just ends up returning an empty string - I've checked 
> to make sure that the call to FOnIdentify is indeed returning values.
> So the question is: how should I be returning a widestring in the 
> TDispParams?



More information about the Delphi mailing list