home *** CD-ROM | disk | FTP | other *** search
/ CD Shareware Magazine 1996 December / CD_shareware_12-96.iso / WIN / Programa / TI2860.ZIP / TI2860.ASC < prev   
Encoding:
Text File  |  1996-05-21  |  2.0 KB  |  110 lines

  1.    NUMBER  :  2860
  2.   PRODUCT  :  Delphi
  3.   VERSION  :  1.0
  4.        OS  :  Windows
  5.      DATE  :  May 21, 1996                            
  6.  
  7.     TITLE  :  Basic Delphi DLL template
  8.  
  9. DLL sample
  10.  
  11. Without units
  12.  
  13. First the DLL "framework" that you wanted, save as DLLFRAME.DPR:
  14.  
  15. {---------------------DLLFRAME.DPR--------------------------}
  16. library Dllframe;
  17.  
  18. uses WinTypes;
  19.  
  20. function  GetString : string ; export ;
  21. begin
  22.   Result := 'Hello from the DLL!' ;
  23. end;
  24.  
  25. exports
  26.   GetString;
  27.  
  28. begin
  29. end.
  30. {-----------------------------------------------------------}
  31.  
  32. Now here's the calling program, save it as DLLCALL.DPR:
  33.  
  34.  
  35. {---------------------DLLCALL.DPR---------------------------}
  36. program Dllcall;
  37.  
  38. uses
  39.   Dialogs;
  40.  
  41. {$R *.RES}
  42.  
  43. function GetString : string ; far ; external 'DLLFRAME' ;
  44.  
  45. begin
  46.   MessageDlg( GetString, mtInformation, [ mbOK ], 0 ) ;
  47. end.
  48.  
  49. With units
  50.  
  51. Here's the calling program, save it as DLLCALL.DPR:
  52.  
  53. {---------------------DLLCALL.DPR---------------------------}
  54. program Dllcall;
  55.  
  56. uses
  57.   Dialogs;
  58.  
  59. {$R *.RES}
  60.  
  61. function GetString : string ; far ; external 'MyDLL' ;
  62.  
  63.  
  64. begin
  65.   MessageDlg( GetString, mtInformation, [ mbOK ], 0 ) ;
  66. end.
  67. {-----------------------------------------------------------}
  68.  
  69. The DLL "framework" that you wanted, save as DLLFRAME.DPR:
  70.  
  71. {---------------------DLLFRAME.DPR--------------------------}
  72. library Dllframe;
  73.  
  74. uses DLLUnit;
  75.  
  76. exports
  77.   GetString;
  78.  
  79. begin
  80. end.
  81. {-----------------------------------------------------------}
  82.  
  83. The unit we will save as dllunit.pas:
  84.  
  85. {---------------------dllunit.pas--------------------------}
  86.  
  87. unit DLLUnit;
  88. interface
  89.  
  90. uses WinTypes;
  91.  
  92. function GetString: string; export;
  93.  
  94. implementation
  95.  
  96. function GetString: string;
  97. begin
  98.   GetString := 'Hello from the DLL!' ;
  99. end ;
  100.  
  101. begin
  102. end.
  103.  
  104.  
  105.  
  106. DISCLAIMER: You have the right to use this technical information
  107. subject to the terms of the No-Nonsense License Statement that
  108. you received with the Borland product to which this information
  109. pertains.
  110.