Solved

OLE Automation Problem

Posted on 2004-04-06
2
244 Views
Last Modified: 2010-04-05
I am trying to do some OLE automation.

There are two possible scenarios that occur when my client tries to "talk" to my server.


A.   Server is already running.  Client does its thing properly, and when finished, the server keeps running.  (This is the desired behavior)

B.   Server is not already running.  When client requests the interface, the server EXE is automatically launches and the client does its thing properly.  This is good.  However, as soon as the client is done with the interface, the server EXE closes.  (This is not the desired behavior)


In scenario B, how do I make it so the server continues to run after the client is done with it?  (i.e., never automatically closes)
0
Comment
Question by:scrapdog
2 Comments
 
LVL 26

Accepted Solution

by:
Russell Libby earned 500 total points
ID: 10769172
Catch and handle the ComServer.OnLastRelease

simplified (but functional) example

type
  TComHandler = class(TObject)
  public
     procedure OnLastRelease(var Shutdown: Boolean);
  end;

procedure TComHandler.OnLastRelease(var Shutdown: Boolean);
begin
  Shutdown:=False;
end;

initialization

  TAutoObjectFactory.Create(ComServer, TMemoApp, Class_MemoApp, ciSingleInstance, tmApartment);

  if (ComServer.StartMode = smAutomation) then
  begin
     with TComHandler.Create do ComServer.OnLastRelease:=OnLastRelease;
  end;


Regards,
Russell

0
 
LVL 5

Author Comment

by:scrapdog
ID: 10769245
Excellent.  Thanks.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question