COM DLL Shutdown when main exe closes

Giganews Newsgroups
Subject:COM DLL Shutdown when main exe closes
Posted by: Bryan Thorell (bthore…@managementplus.com)
Date:Tue, 28 Sep 2010

I have recently changed our application to load the COM DLL's more
dynamically to save memory.

I have created functions like:

function CurrentInventory : IInventory;
begin
  CurrentInventory := CoInventory.Create;

  CurrentInventory.PassInterface('CONNECTION', CurrentConnection);
  CurrentInventory.PassInterface('STAFF', CurrentStaff);
end;

so I can easily just call the methods of the DLL and if it's not
initialized, then it will initialize it.  Also when the variable is
out of scope it will be nilled right?  and thus free the objects.

The only issue I have is now when I have a screen open in one of the
dlls and close the main exe down, the form being displayed in the dll
just sits there frozen.

Any ideas on how to better handle this?

THanks

Bryan

Replies