Board index » delphi » COM Object Shut Down?

COM Object Shut Down?

I have a COM Object that displays a form.  The form has a close button on it
which closes the form - is there a way to free/destroy the COM object as
well from the close button?  Kind of like having the COM object free itself
as opposed to the calling EXE freeing the COM Object.

Thanks!

Shawn M. Reed

 

Re:COM Object Shut Down?


Quote
Shawn M. Reed wrote in message <6t6gad$8p...@forums.borland.com>...
>I have a COM Object that displays a form.  The form has a close button on
it
>which closes the form - is there a way to free/destroy the COM object as
>well from the close button?  Kind of like having the COM object free itself
>as opposed to the calling EXE freeing the COM Object.

Nope.  To do so would defeat the entire meaning and advantage of COM
interfaces.  In the COM world (and generally, in any garbage-collected
world), the holding of a reference to something guarantees that that
something will not go away before you release your reference to it.
Everybody writes code assuming this contract is in place, so your COM object
wouldn't be very usable by others if they couldn't rely on this.  Since
presumably the reason why you're making the COM object in the first place
(rather than, say, the substantially simpler approach of exporting a
function from your DLL) is that you want COM clients (like VB) to be able to
use your form, then you should expect to follow the contract.

That said, you certainly can reduce your COM object's size in memory when
not "active", by making sure the form gets deleted when it closes, and
making sure you only create the form when you are asked to by the COM
client.

-- Conrad Herrmann

Re:COM Object Shut Down?


It would be nice to be able to have a COM object destroy itself (security
reasons for example). Is this not possible?

How can I ensure that only those clients I trust are creating my COM
objects? Must I code something myself - such as a challenge/response
algorithm? Is there any built in security with COM?

thx.

Other Threads