Board index » delphi » VB Guru/Delphi Guru Please Help Me with OLE question

VB Guru/Delphi Guru Please Help Me with OLE question

I have a VB program which does the following

Dim myEngine as object
Dim myEnvironment as object
Dim myConnection as object

myEngine = GetObject("metaDB.mdbEngine")
myEnvironment=myEngine.mdbEnvironments(0)
myConnection=myEnvironment.OpenConnection

I need to access the same OLE DLL in Delphi and I have no idea where to
start!

 

Re:VB Guru/Delphi Guru Please Help Me with OLE question


Quote
>   Max Young <myo...@powerup.com.au> writes:
>  I need to access the same OLE DLL in Delphi and I have no idea where to
>  start!

This is a VERY simple test that I made myself to get started with OLE. I was asked to add OLE support to a program I made and this
is what I did to have a program to test that my own OLE server worked.

This creates the oleobject upon creation and then whenever you press a button it calls a procedure in the oleserver.

johan

.....

unit oletestu;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
     ttsesed : variant;
  end;

var
  Form1: TForm1;

implementation
uses oleauto;
{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
begin
  ttsesed := createoleobject('ttdewed.ttsesole');
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  ttsesed.openeditfile;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  ttsesed.appshow;
end;

end.

Re:VB Guru/Delphi Guru Please Help Me with OLE question


You need to define your "OLE Object" variable as a Variant and call
CreateOLEObject.
The "stuff" you need is in the OLEAuto unit (contrary to documentation that
says it's ComObj).

var MyEngine : Variant;

MyEngine := CreateOLEObject('metaDB.mdbEngine');
...

From there on in, you can use MyEngine just like you did in VB.

Tony

Max Young <myo...@powerup.com.au> wrote in article
<3302A5BE.7...@powerup.com.au>...

Quote
> I have a VB program which does the following

> Dim myEngine as object
> Dim myEnvironment as object
> Dim myConnection as object

> myEngine = GetObject("metaDB.mdbEngine")
> myEnvironment=myEngine.mdbEnvironments(0)
> myConnection=myEnvironment.OpenConnection

> I need to access the same OLE DLL in Delphi and I have no idea where to
> start!

Re:VB Guru/Delphi Guru Please Help Me with OLE question


On 14 Feb 1997 05:48:51 GMT, "Tony Brummel" <tony...@ibm.net> wrote:

Quote
>You need to define your "OLE Object" variable as a Variant and call
>CreateOLEObject.
>The "stuff" you need is in the OLEAuto unit (contrary to documentation that
>says it's ComObj).

>var MyEngine : Variant;

>MyEngine := CreateOLEObject('metaDB.mdbEngine');
>...

>From there on in, you can use MyEngine just like you did in VB.

>Tony

>Max Young <myo...@powerup.com.au> wrote in article
><3302A5BE.7...@powerup.com.au>...
>> I have a VB program which does the following

>> Dim myEngine as object
>> Dim myEnvironment as object
>> Dim myConnection as object

>> myEngine = GetObject("metaDB.mdbEngine")
>> myEnvironment=myEngine.mdbEnvironments(0)
>> myConnection=myEnvironment.OpenConnection

>> I need to access the same OLE DLL in Delphi and I have no idea where to
>> start!

Thanks - I tried & it didn't work - I get an error on the
myEngine.Environments(0) line (though as I'm typing this I suddenly
thought "perhaps I should use [0] not (0)?

Max

Other Threads