Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Early Binding in Delphi 3

10 views
Skip to first unread message

Hopeton Palmer

unread,
Jan 11, 1998, 3:00:00 AM1/11/98
to

What are the steps necessary for early binding in Delphi 3?
Where can I get more information on early binding in Delphi?
Can anyone provide an example using one of the Office 97 components?

Any help would be highly appreciated!
Thanks.

Scott Samet [TeamB]

unread,
Jan 11, 1998, 3:00:00 AM1/11/98
to

In article <69bets$9d...@forums.borland.com>, Hopeton Palmer wrote:

> What are the steps necessary for early binding in Delphi 3?

1. You must have a typelib, either as a .tlb, or inside the .exe or
dll
2. Use Project | ImportTypelib to read the .tlb, .exe or .dll and
create a Delphi xxx_tlb.pas file.
3. Use the xxx_tlb unit in your code, and you'll have early binding.

This example shows early binding to the SQL Server DMO OLE interface.
SQLServer, Database and Table are all Interfaces defined in the
SQLOLE_TLB unit, created from \MSSQL\BINN\SQLOLE65.tlb

uses
SQLOLE_TLB;

var // all from the SQLOLE_TLB unit
FSQLServer: SQLServer;
Fdatabase: Database;
FTable: Table;

FSQLServer := coSQLServer.Create;
// two alternate ways to create the SQL Server object if there's no
coClass:
// FSQLServer := CreateComObject (Class_SQLServer) as SQLServer;
// FSQLServer := CreateOLEObject ('SQLOLE.SQLServer') as SQLServer;
FSQLServer.NetPacketSize := 8192;
with FSQLServer.Application.Properties do
For I := 1 to Count do
With Item(I) do
Memo1.Lines.Add (Format ('%s=%s', [Name, Value]));

Ben Geerdes

unread,
Jan 12, 1998, 3:00:00 AM1/12/98
to

I am trying to do similar thing with Word97, but havent't figured out yet
how to
handle optional parameters. I thought that if a parameter is optional I can
use a
OLEVariant which is assigned the UnAssugned value, but that does not work?

Any suggestions?

Thanks

Ben

Scott Samet [TeamB] wrote in message ...

Gerard Pierce

unread,
Jan 12, 1998, 3:00:00 AM1/12/98
to

Ben,

In early binding, by experiment, I found that you have to specify _all_
values in the function call and if you aren't actually using them you still
have to supply some value for each parameter --> i.e. parm1 := ''; parm2 :=
false: etc.

It makes sense since you don't have the compiler or the IDispatch interface
to scan the parameters. You are directly calling the object's function.

--
Gerry Pierce

======================================
When you come to a fork in the road, take it.
- Yogi Berra
======================================

Ben Geerdes wrote in message <69dhs5$ac...@forums.borland.com>...

Tony Tanzillo

unread,
Jan 12, 1998, 3:00:00 AM1/12/98
to

You can pass this variant in cases where you don't want
to specify a value for an optional parameter:"

var
Nothing : OleVariant;
begin
TVarData(Nothing).VType := varError;
TVarData(Nothing).VError := DISP_E_PARAMNOTFOUND

Scott Samet [TeamB]

unread,
Jan 12, 1998, 3:00:00 AM1/12/98
to

In article <69dvq0$ai...@forums.borland.com>, Tony Tanzillo wrote:

> TVarData(Nothing).VType := varError;
> TVarData(Nothing).VError := DISP_E_PARAMNOTFOUND

How did you find this?


jmerril...@mnsinc.com

unread,
Jan 13, 1998, 3:00:00 AM1/13/98
to

I believe that the following will work to make an optional parameter:

var Nothing:OleVariant;
....
TVarData(Nothing).VType:=varError;
TVarData(Nothing).VError:=DISP_E_PARAMNOTFOUND;


Tony Tanzillo

unread,
Jan 13, 1998, 3:00:00 AM1/13/98
to

By digging through the MSVC++ online documentation.

Scott Samet [TeamB] wrote in message ...

Peter Hagerty

unread,
Jan 22, 1998, 3:00:00 AM1/22/98
to

Could you post an example of it's use with Word 97 - I'm still very confused
and when I tried this 'nothing' function I got a message along the lines of
parameter types must match exactly...

jmerril...@mnsinc.com wrote in message
<09980012125246.OUI...@mnsinc.com>...

J. Merrill

unread,
Jan 22, 1998, 3:00:00 AM1/22/98
to

You can only use this with a Word97 function that has optional
parameters. An untested example is that the Delphi code
v.ActiveDocument.Close(wdSaveChanges, Nothing, Nothing) should be the
same as ActiveDocument.Close(wdSaveChanges)
in VBA.

It is odd to me that VBA likes a "param not found error variant" for
optional parameters (vs Unassigned or Null), but little that MS is doing
here makes a lot of sense to me...


Tony Tanzillo

unread,
Jan 27, 1998, 3:00:00 AM1/27/98
to

This is got nothing to do with VBA, the placeholder is part of
the OLE Automation specification.

J. Merrill wrote in message <09980022172852.OUI...@mnsinc.com>...

J. Merrill

unread,
Jan 27, 1998, 3:00:00 AM1/27/98
to

Yes, you're right -- it's not VBA that has this odd notion "optional
parameters are passed as missing by building an Error variant that has a
particular error type" -- it's all of OLE Automation.

It's just bizarre that an optional parameter is a type of error! But
once you know the mystical incantation for making that Nothing variant,
it all becomes easy.

--
- J. Merrill jmerril...@mnsinc.com

0 new messages