Solved

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

Posted on 2000-05-10
4
166 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
  • 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 100 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi 2010 Export to pdf 2 330
add combobox item based on numbers 9 141
Firemonkey DbLookupComboBox equivalent ? 2 47
Tidtcpserver listening on multiports? 1 26
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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

805 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