Technical Information Database TI938D.txt Basic Delphi DLL templateCategory :General ProgrammingPlatform :AllProduct :Delphi 1.0 Description: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; beginend.{-----------------------------------------------------------} Now here's the calling program, save it as DLLCALL.DPR: {---------------------DLLCALL.DPR---------------------------}program Dllcall; usesDialogs;
{$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; usesDialogs;
{$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 ; beginend. Reference: 7/16/98 4:33:57 PM
Last Modified: 01-SEP-99