Solved

OLE Automation Problem

Posted on 2004-04-06
2
238 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
Comment Utility
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
Comment Utility
Excellent.  Thanks.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 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

11 Experts available now in Live!

Get 1:1 Help Now