Solved

OLE Automation Problem

Posted on 2004-04-06
2
243 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

815 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now