Mega Code Archive

 
Categories / Delphi / System
 

Making a DLL with Delphi

Title: Making a DLL with Delphi Question: How I need to make a DLL ??? How I need to call it later ??? Simple, view the demo... Answer: //--------------------------------------------------------------------------- // Author : Digital Survivor [Esteban Rodrguez Nieto | Jos Plano] // Email : plmad666@gmail.com | jose.plano@gmail.com // Web site : www.ds-studios.com.ar //--------------------------------------------------------------------------- The code below creates a simple DLL with one procedure called "Test DLL". The result of this procedure is a message box with some test. It's very simple and easy to make. Enjoy. Library Test; { The Delphi 5 help recomend to add the ShareMem unit at the begining of the uses clauses to improve the memory management and the export strings callings. } Uses ShareMem, SysUtils, Windows, Dialogs; {$R *.RES} Const TestConst = 'This is a tests DLL.'; { It's recomended to use the StdCall parameter for define the standar calling method. This generally make our DLL compatible with any language... Procedure TestDLL (TestStr : String); Stdcall Begin MessageDlg (TestConst + Chr (13) + Chr (13) + 'Your string is: ' + TestStr, mtInformation, [mbOk], 0); End; Exports TestDLL; // This is needed to make the funcion available later... Begin End. ---------------------------------------------------------------------- Add this line in your program to declare the procedure in the DLL. Remember to copy the DLL to the directory where the program is. Procedure TestDLL (TestStr : Sting); Stdcall; External 'Test.dll'; Any comments are welcome. Enjoy. MAD666.