Neven,

1.
CreateOLEObject returns the IDispatch interface for the object not 
the interface as you are thinking. This is why the assignment fails.
You will need to obtain the correct interface using 

        as  (performs a behind scene QueryInterface for you)

before attemting to use the actual interface methods.

Given that you have imported the Type Library it will probably be better to
use
early binding.

2.
When the interface referance goes out of scope (end of method) Delphi will 
automatically perform the _Release for you. If you want to this earlier then

set the interface to nil (which will cause the _Release).
Don't call _Release directly and then set the interface to nil. This caused
me 
some great fun until I worked out what Delphi was doing for me behind the
scenes.



Regards

Andrew Dibley


> -----Original Message-----
> From: Neven MacEwan [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, 28 March 2001 17:00
> To: Multiple recipients of list delphi
> Subject: [DUG]: COMmunication Breakdown
> 
> 
> Hi all
> 
> I'm interfacing with a coupla VB6 Com objects and though I 
> have got it to
> work i don't quite know how!
> 
> object COMa and COMb, COMb exposes a property a of 'type' COMa
> 
> it works if I import the TL and use the CoClass create to 
> explicitly create
> an instance of COMa of the type interface that COMb expects
> 
> ie
> 
> var
>    COMa: COMaIF; // from TLB IDispatch desc
>    COMb: COMbIF; // from TLB IDispatch desc
> 
>    COMa := CoCOMaIF.Create;
>    COMb := CoCOMbIF.Create;
> 
>    COMb.a := COMa; // works
> 
> but if I 'Late bind' ie let COM work it all out it fails
> 
> var
>    COMa, COMb: variant;
> 
>    COMa := CreateOLEObkect('COMa.Function');
>    COMb := CreateOLEObkect('COMb.Function');
> 
>    COMb.a := COMa; // fails
> 
> also when you create an interface in the first method how can 
> you free it.
> ie you set a varient to NULL but do you assign an interface nil?
> 
> TIA
> 
> Regards Neven
> N.K. MacEwan B.E. E&E
> Ph 649 574 0027
> Fax 649 570 2706
> 
> "A truth denied the light of action will wither to a promise, 
> propaganda and
> then a lie"
> 
> --------------------------------------------------------------
> -------------
>     New Zealand Delphi Users group - Delphi List - 
> [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED] 
> with body of "unsubscribe delphi"
> 
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"

Reply via email to