Board index » delphi » Please Help DLL!!!! Writing a simple DLL

Please Help DLL!!!! Writing a simple DLL

Hello,

i am trying to write a very simple DLL in Delphi.
Which has just one function EntryPoint which i am trying to call from another delphi
app.
The calling program is unable to find that function.
Can any body please help me what is misssing in my code.

when i run the Caller program, it successfully loads the DLL but does not find the
function and gives the Message
'Function not found'

and when i try to call the pocedure EntryPoint it gives runtime error that function not
found in the specified DLL.

Thanx for ur help inadvance.
regards

Zeeshan

2-------- DLL code -----
library Gen2000;

uses
  ShareMem,
  SysUtils,
  Dialogs,
  Classes;

begin
  ShowMessage('DLL Loaded');
end.

procedure EntryPoint;
begin
  ShowMessage('Inside EntrPoint');
end

exports
  EntryPoint index 1
begin

-------Caller program --------
program CallDLL;

uses
  Forms,
  Dialogs,
  sysutils,
  windows;

 procedure EntryPoint; external 'c:\windows\system\gen2000.dll' index 1;

{$R *.RES}
var
  H1: DWORD;
  H2 : Pointer;

begin
  Application.Initialize;
  H1 := LoadLibrary('C:\windows\system\gen2000');
  H2 := GetProcAddress(H1, 'EntryPoint');
  if H2=nil then ShowMessage('Function NOT found')
  else ShowMessage('Function found');

  //EntryPoint;
  Application.Run;
end.

-------

 

Re:Please Help DLL!!!! Writing a simple DLL


You didn't export the procedure. Try the following, it might work.

library Gen2000;

 uses
   ShareMem,
   SysUtils,
   Dialogs,
   Classes;

 exports
    Entrypoint;

 procedure EntryPoint;
 begin
   ShowMessage('Inside EntrPoint');
 end;

 begin
   ShowMessage('DLL Loaded');
 end.

syst...@primenet.com wrote in article <331C1CCE.2...@primenet.com>...

Quote
> Hello,

> i am trying to write a very simple DLL in Delphi.
> Which has just one function EntryPoint which i am trying to call from
another delphi
> app.
> The calling program is unable to find that function.
> Can any body please help me what is misssing in my code.

> when i run the Caller program, it successfully loads the DLL but does not
find the
> function and gives the Message
> 'Function not found'

> and when i try to call the pocedure EntryPoint it gives runtime error
that function not
> found in the specified DLL.

> Thanx for ur help inadvance.
> regards

> Zeeshan

Re:Please Help DLL!!!! Writing a simple DLL


On 3/4/97 2:08PM, in message <331C1CCE.2...@primenet.com>, syst...@primenet.com wrote:

Quote
> Hello,

> i am trying to write a very simple DLL in Delphi.
> Which has just one function EntryPoint which i am trying to call from another delphi
> app.
> The calling program is unable to find that function.

> procedure EntryPoint;
> begin
>   ShowMessage('Inside EntrPoint');
> end

The above code needs to read:
procedure EntryPoint;
begin
  ShowMessage('Inside EntrPoint'); export;
end
--
******************************************************************************
Life is like a sewer:
    What you get out of it
    Depends on what you put into it
******************************************************************************

Other Threads