home *** CD-ROM | disk | FTP | other *** search
- NUMBER : 2860
- PRODUCT : Delphi
- VERSION : 1.0
- OS : Windows
- DATE : May 21, 1996
-
- TITLE : Basic Delphi DLL template
-
- 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.
-
-
-
- DISCLAIMER: You have the right to use this technical information
- subject to the terms of the No-Nonsense License Statement that
- you received with the Borland product to which this information
- pertains.
-