- - * - WhiteUnicorn - * - -




* #WhiteUnicorn/ StartPage/ Documentation/DelphiFAQ >


2860:Basic Delphi DLL template

KEYWORDS: DLL template AREA: General

DLL sample

Without units

First the DLL "framework" that you wanted, save as DLLFRAME.DPR:

{---------------------DLLFRAME.DPR--------------------------}
library Dllframe;

uses WinTypes;

function  GetString : string ; export ;
begin
  Result := 'Hello from the DLL!' ;
end;

exports
  GetString;

begin
end.
{-----------------------------------------------------------}

Now here's the calling program, save it as DLLCALL.DPR:


{---------------------DLLCALL.DPR---------------------------}
program Dllcall;

uses
  Dialogs;

{$R *.RES}

function GetString : string ; far ; external 'DLLFRAME' ;

begin
  MessageDlg( GetString, mtInformation, [ mbOK ], 0 ) ;
end.

With units

Here's the calling program, save it as DLLCALL.DPR:

{---------------------DLLCALL.DPR---------------------------}
program Dllcall;

uses
  Dialogs;

{$R *.RES}

function GetString : string ; far ; external 'MyDLL' ;


begin
  MessageDlg( GetString, mtInformation, [ mbOK ], 0 ) ;
end.
{-----------------------------------------------------------}

The DLL "framework" that you wanted, save as DLLFRAME.DPR:

{---------------------DLLFRAME.DPR--------------------------}
library Dllframe;

uses DLLUnit;

exports
  GetString;

begin
end.
{-----------------------------------------------------------}

The unit we will save as dllunit.pas:

{---------------------dllunit.pas--------------------------}

unit DLLUnit;
interface

uses WinTypes;

function GetString: string; export;

implementation

function GetString: string;
begin
  GetString := 'Hello from the DLL!' ;
end ;

begin
end.


        TI



* #WhiteUnicorn/ StartPage/ Documentation/DelphiFAQ >



- - * - Anastasija aka WhiteUnicorn - * - - LJLiveJournal
PFPhotoFile