Link to home
Start Free TrialLog in
Avatar of smurff
smurff

asked on

OLE - how to create out of process server for another App

I have made an app that checks for a server on the LAN, if its there create a file there on a shared dir. Wait for another file to be created then I read the new file in and save the contents in a string. Now ive been told that theres a program developed that will need to run my app, parse some info wait for the my app to finish then use the info I got. Ive been told that the only way it will comunicate is with ole. So, sorry to ramble but how do I make my app a ole server/whatever?
MAny, many thanks to anyone who can help.
Smurff
Avatar of mullet_attack
mullet_attack

Delphi 5 help is very good on this subject. Find this bit below, and follow the links

Creating an Automation object for an application

An Automation object is an ObjectPascal class descending from TAutoObject that supports OLE Automation, exposing itself for other applications to use. Since TAutoObject supports OLE Automation, any object derived from it gets Automation support automatically. You create an Automation object using the Automation Object wizard.
Before you create an Automation object, create or open the project for an application containing functionality that you want to expose. The project can be either an application or ActiveX library, depending on your needs.

To display the Automation wizard:

1      Choose File|New.
2      Select the tab labeled, ActiveX.
3      Double-click the Automation Object icon.

In the wizard dialog, specify the following:

CoClass Name      Specify the class whose properties and methods you want to expose to client applications. (Delphi prepends a T to this name.)
Instancing      Specify an instancing mode to indicate how your Automation server is launched.Note: When your Automation object is used only as an in-process server, instancing is ignored.
Threading Model      Choose the threading model to indicate how client applications can call your object’s interface. This is the threading model that you commit to implementing in the Automation object. Note: The threading model you choose determines how the object is registered. You must make sure that your object implementation adheres to the model selected.
Generate event support code      Check this box to tell the wizard to implement a separate interface for managing events of your Automation object.
When you complete this procedure, a new unit is added to the current project that contains the definition for the Automation object. In addition, the wizard adds a type library project and opens the type library. Now you can expose the properties and methods of the interface through the type library as described in Exposing the application’s properties and methods for Automation.
The Automation object implements a dual interface, which supports both early (compile-time) binding through the VTable and late (runtime) binding through the IDispatch interface.  
Avatar of smurff

ASKER

Thanks for your reply. I have testede what you said and I understand how it works now but I still have a small problem. I have my application with Form1 and 4 procedures, then after your advice, I added a Automation object which added unit2.pas and Project1_tlb. From unit2 I made a procedure helloworld and all it did was showmessage(param1); it worked fine but what I need to do is to call the procedures and labels from form1. I just cant seem to do it. does anyone have an example I could look thought or ay help?
ASKER CERTIFIED SOLUTION
Avatar of mullet_attack
mullet_attack

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of smurff

ASKER

Fantastic, just wht I needed, I couldnt seem to interact the form with unit2. Cheers for your time and answer.
Smurff