Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2000-05-10
4
Medium Priority
?
173 Views
Last Modified: 2010-04-04
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
0
Comment
Question by:smurff
[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
  • 2
  • 2
4 Comments
 
LVL 2

Expert Comment

by:mullet_attack
ID: 2798119
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.  
0
 
LVL 3

Author Comment

by:smurff
ID: 2803694
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?
0
 
LVL 2

Accepted Solution

by:
mullet_attack earned 400 total points
ID: 2804089
I created a new app, normal exe. A form with one label control on it, nothing else.

Then I selected new > activeX > automation object, which added the tlb and unit2.

I defined a method 'SetCaption' in the type library, and saved it.

I added unit1 to the uses clause of unit 2, and added the code to the implementation of SetCaption in unit2.

here are the units.

unit1
--------------------------------
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Label1: TLabel;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

end.


unit2
-----------------------------
unit Unit2;

interface

uses
  ComObj, ActiveX, Project1_TLB, StdVcl, unit1;

type
  TComTest = class(TAutoObject, IComTest)
  protected
    procedure SetCaption(const Text: WideString); safecall;
    { Protected declarations }
  end;

implementation

uses ComServ;

procedure TComTest.SetCaption(const Text: WideString);
begin
   Form1.label1.caption := text;
end;

initialization
  TAutoObjectFactory.Create(ComServer, TComTest, Class_ComTest,
    ciMultiInstance, tmApartment);
end.


hope this helps
0
 
LVL 3

Author Comment

by:smurff
ID: 2809856
Fantastic, just wht I needed, I couldnt seem to interact the form with unit2. Cheers for your time and answer.
Smurff
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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

636 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