Board index » delphi » Freeing COM-objects in a COM-Client?

Freeing COM-objects in a COM-Client?

Hi!
Maybe this is a dumb question.
If I declare a variable as say myCOMobj: IMyInterface and then assigned it like this myCOMObj:=CreateOleObject('myautoobj.myclass'); do I have to free it before I assign it to a new object?
I have seen something like this as well.
 myObj: Variant;
begin
 myobj:=CreateOle...
 myObj:=Unassigned;

but you cant unassign an interface-varible, or?

/Mike

 

Re:Freeing COM-objects in a COM-Client?


hi,

you can. An interface variable, of the type ImySerevr (ie), is actually a
pointer (to apointer etc.)
so you program.

IMyInterface:= nil;

Which will result in a release on ther server.

--
Peter.van.Ooi...@Gekko-Software.nl
http://www.Gekko-Software.nl/Delphi

Quote
"Mike" <m...@hotmail.com> wrote in message news:3bbb619d$1_2@dnews...

> Hi!
> Maybe this is a dumb question.
> If I declare a variable as say myCOMobj: IMyInterface and then assigned it

like this myCOMObj:=CreateOleObject('myautoobj.myclass'); do I have to free
it before I assign it to a new object?
Quote
> I have seen something like this as well.
>  myObj: Variant;
> begin
>  myobj:=CreateOle...
>  myObj:=Unassigned;

> but you cant unassign an interface-varible, or?

> /Mike

Re:Freeing COM-objects in a COM-Client?


Quote
> IMyInterface:= nil;

> Which will result in a release on ther server.

Does it mean that this assignment statement internally calls
  IMyInterface.Release;
?

Ivan

Other Threads