[DUG] Returning a WideString in an Invoke Param

Phil Middlemiss phil at tumonz.co.nz
Tue Jul 18 12:35:52 NZST 2006


I'm using Delphi6 which allows the ^ to be optional if the pointer is a 
typed pointer.

Todd Martin wrote:
> Actually I've spotted an error in your code....and my example.
>
> rgvarg is of type PVariantArgList, so you need to dereference the 
> pointer to the variant list and then index the array.
>
> Like so
>
> funtion getParameter(Params : TDispParams; AIndex : Integer) : 
> OleVariant;
> begin
>  Result:= Params.rgvarg^[AIndex ];
> end;
>
> ----- Original Message ----- From: "Phil Middlemiss" <phil at tumonz.co.nz>
> To: "NZ Borland Developers Group - Delphi List" <delphi at ns3.123.co.nz>
> Sent: Tuesday, July 18, 2006 11:59 AM
> Subject: Re: [DUG] Returning a WideString in an Invoke Param
>
>
>> No, it's not in a DLL. It's the automatically generated events object
>> that the Automation wizard produces when creating an automation server
>> with events. It's for use in the client app that will connect to the
>> automation server in order to respond to the events that the automation
>> server fires.
>>
>> Perhaps I need to use OleVariants. Infact, the actual parameters may be
>> OleVariants instead of bstrVal types.
>>
>> Phil.
>>
>> Rohit Gupta wrote:
>>> Is this code in a DLL ?  If so then you can not transfer ansistrings 
>>> unless you
>>> use a sharememory kludge.
>>>
>>> Last time I chose to use shortstrings to get around this.  That 
>>> worked fine
>>> except in some instances on some PCs, the exceptions would not work...
>>> When I thought about it, the exception object itself uses 
>>> ansistring.  So
>>> Borlands staement is not true.... if the DLL can possible raise an 
>>> exception,
>>> it uses ansistring and you need to use sharemem.
>>>
>>> Date sent: Tue, 18 Jul 2006 11:13:50 +1200
>>> From: Phil Middlemiss <phil at tumonz.co.nz>
>>> Organization: MTS Ltd
>>> To: NZ Borland Developers Group - Delphi List <delphi at ns3.123.co.nz>
>>> Subject: [DUG] Returning a WideString in an Invoke Param
>>> Send reply to: NZ Borland Developers Group - Delphi List 
>>> <delphi at ns3.123.co.nz>
>>> <mailto:delphi-request at ns3.123.co.nz?subject=unsubscribe>
>>> <mailto:delphi-request at ns3.123.co.nz?subject=subscribe>
>>>
>>> Hi all,
>>>
>>> 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?
>>>
>>> Cheers,
>>> Phil.
>>> Regards
>>>
>>> Rohit
>>>
>>> ======================================================================
>>> CFL - Computer Fanatics Ltd.  21 Barry's Point Road, AKL, New Zealand
>>> PH    (649) 489-2280
>>> FX    (649) 489-2290
>>> email rohit at cfl.co.nz  or  r.gupta at xtra.co.nz
>>> ======================================================================
>>>
>>>
>>> _______________________________________________
>>> Delphi mailing list
>>> Delphi at ns3.123.co.nz
>>> http://ns3.123.co.nz/mailman/listinfo/delphi
>>>
>>>
>>>
>>>
>>
>
>
> -------------------------------------------------------------------------------- 
>
>
>
>> _______________________________________________
>> Delphi mailing list
>> Delphi at ns3.123.co.nz
>> http://ns3.123.co.nz/mailman/listinfo/delphi
>>
>
>
> -------------------------------------------------------------------------------- 
>
>
>
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.1.394 / Virus Database: 268.10.1/389 - Release Date: 
> 14/07/2006
>
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: phil.vcf
Type: text/x-vcard
Size: 250 bytes
Desc: not available
Url : http://ns3.123.co.nz/pipermail/delphi/attachments/20060718/0ac024f1/phil.vcf


More information about the Delphi mailing list