Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Out Process COM Server using Delphi 4 ????

Posted on 1999-09-30
1
Medium Priority
?
358 Views
Last Modified: 2012-05-05
I am currently working on an out process com server using delphi. This
out process com server has a set of interfaces, with no co classes.
There is one main interface 'Imain' through which the other interfaces
can be obtained. The com client that uses this com server will be using
just one Imain interface to talk to the com server. This Imain interface has to be obtained from the com server which will be internally
instantiating the object and then providing the interface to the com client.

The problem is that I just can't find a way to do this. I.e.
instantiating the object within the com server and then passing on the
interface to the com client.

One good example of this situation would be that suppose I am developing

microsoft word and when I am working with another application, I can
talk to microsoft word com server and set certain global properties like

activedocument, without having to instantiate microsoft word object
myself. The com server does it for me. I want the same kind of
functionality to be provided by my com server.

Any example code for the com server would be appreciated.

Please note that all my interface implementation classes are derived
from TAutoIntfObject.

Your prompt response is eagerly awaited

Thank you,
0
Comment
Question by:Goradia
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 2

Accepted Solution

by:
EdHillmann earned 200 total points
ID: 2350861
Hi Goradia.  If I understand correctly, Delphi should be able to handle the main COM Implementation (read Server) object instantiation as long as it's defined as a TAutoObject.  When you use a TAutoObject, it will associate it with a ClassFactory, and the Factory is what the Windows system uses to create the server object.  And it's this Server object that gets passed back to the client.

For example, if I was starting from scratch, I'd start a new application.  Then create a New Automation Object (providing its Name and Instantiation).  This will be your main interface (we'll call it IMainInterface for clarity).  This will provide you with a type library and an implementation unit.  If you notice the bottom of the implementation unit, you'll see a line that creates the AutoObjectFactory.

So, now in your type library, you can define your remaining interfaces in the type library without creating corresponding CoClasses.

Once you have all the interfaces defined (with still only one CoClass, which will be called MainInterface going by our example), you can define the functions/properties on IMainInterface that allows a client to access another interface.  The IDL, would look like this...

   interface IMainInterface: IDispatch
  {
    [propget, id(0x00000001)]
    HRESULT _stdcall Property1([out, retval] ISubIntf1 * Value );
  };

The above example is IMainInterface which has a property which returns an implementation of the ISubIntf1 (where ISubIntf1 is defined in IMainInterface's type library).

That's the deal on the interface.  As far as the implementation object for IMainInterface, it would need to construct the TAutoIntfObject's during it's Initialize procedure.  Not it's Create procedure.  And it's interface functions would then provide the appropriate TAutoIntfObjects for the IMainInterface function call.

Note: you could also delay the AutoIntf object construction until the first time the appropriate function is called...

The only thing you'd want to remember is to handle the AutoIntf objects when the TAutoObject is destroyed.

Hope this helps.  Let me know if you want more details.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

721 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