Board index » delphi » PLEASE HELP! Calling DLL functions from a Delphi 1 app

PLEASE HELP! Calling DLL functions from a Delphi 1 app

Hi,

Probably a 'dumb newbie' type question to some of you, but I'm desperate
for a solution and have no pride!
I'm trying to access functions in a 16-bit DLL, written by a
third-party in C++.  I'm using Delphi 1 under Windows 3.11.

Specifically, the compiler complains whenever I put the function
declaration and 'external' keyword in the 'interface' section of my
code module.  
I've followed the on-line help to the letter, and as
far as I can see it's either wrong or missing something really
important!

Variations on the theme even include a system-level application
error complaining of an unspecified Dynalink ?!?!?!?!?!

I can't find anything to help me.  Most literature seems to
pertain to Delphi 2.

Can anyone help?

=====================================================
Karl D Soar, Researcher  | "What Englishman will turn
School of Construction   | his mind to politics
Sheffield Hallam Uni.    | if he can afford to keep
k.d.s...@shu.ac.uk       | a car?"
phone :  +44 114 2533599 |      - George Bernard Shaw
=====================================================

 

Re:PLEASE HELP! Calling DLL functions from a Delphi 1 app


On Tue, 03 Jun 1997 10:04:39 -0700, Karl Soar <k.d.s...@shu.ac.uk>
wrote:

Quote
>Hi,

>Probably a 'dumb newbie' type question to some of you, but I'm desperate
>for a solution and have no pride!
>I'm trying to access functions in a 16-bit DLL, written by a
>third-party in C++.  I'm using Delphi 1 under Windows 3.11.

>Specifically, the compiler complains whenever I put the function
>declaration and 'external' keyword in the 'interface' section of my
>code module.  
>I've followed the on-line help to the letter, and as
>far as I can see it's either wrong or missing something really
>important!

The "external" portion of the declaration needs to be in the
implmentation section of the unit, as that effectively IS the
"implementation" of that function as far as the unit is concerned:

unit Foo ;
interface

uses
  Whatever ;

function ImportedCFunc( someparam : sometype ): someothertype ;

implementation

function ImportedCFunc( someparam : sometype ): someothertype ;  
  external 'DLLNAME' index 1 ;

end .

note that you don't have to recapitulate the parameter list and return
type in the implementation section, but I always find it useful to do
so, especially in large import units.

Quote
>Variations on the theme even include a system-level application
>error complaining of an unspecified Dynalink ?!?!?!?!?!

That's a equine possessing variant pigmentation -- Are you sure you
have the DLL name spelled correctly in the function definition?  Is it
located somewhere on the default search path?  You should also know
that D1 doesn't support file extensions in the DLLNAME string,
including one prevents the DLL from being found (if you need to use a
DLL that doesn't have the .DLL extension, you either need to rename it
or use LoadLibrary() instead).

Quote
>I can't find anything to help me.  Most literature seems to
>pertain to Delphi 2.

>Can anyone help?

>=====================================================
>Karl D Soar, Researcher  | "What Englishman will turn
>School of Construction   | his mind to politics
>Sheffield Hallam Uni.    | if he can afford to keep
>k.d.s...@shu.ac.uk       | a car?"
>phone :  +44 114 2533599 |      - George Bernard Shaw
>=====================================================

HTH

Stephen Posey
slpo...@concentric.net

Re:PLEASE HELP! Calling DLL functions from a Delphi 1 app


Quote
Karl Soar wrote:

> Hi,

> Probably a 'dumb newbie' type question to some of you, but I'm desperate
> for a solution and have no pride!
> I'm trying to access functions in a 16-bit DLL, written by a
> third-party in C++.  I'm using Delphi 1 under Windows 3.11.

> Specifically, the compiler complains whenever I put the function
> declaration and 'external' keyword in the 'interface' section of my
> code module.
> I've followed the on-line help to the letter, and as
> far as I can see it's either wrong or missing something really
> important!

> Variations on the theme even include a system-level application
> error complaining of an unspecified Dynalink ?!?!?!?!?!

> I can't find anything to help me.  Most literature seems to
> pertain to Delphi 2.

> Can anyone help?

> =====================================================
> Karl D Soar, Researcher  | "What Englishman will turn
> School of Construction   | his mind to politics
> Sheffield Hallam Uni.    | if he can afford to keep
> k.d.s...@shu.ac.uk       | a car?"
> phone :  +44 114 2533599 |      - George Bernard Shaw
> =====================================================

Karl,

the declaration must be in the implementation section.

- christoph -

Other Threads