> Writing DLLs


 Writing DLLs

The structure of a Borland Pascal DLL is identical to that of a program, except that a DLL starts with a library header instead of a program header.

The library header tells Borland Pascal to produce an executable file with the extension .DLL instead of .EXE. It also ensures that the executable file is marked as being a DLL.

If procedures and functions are to be exported by a DLL, they must be compiled with the export procedure directive.


This implements a very simple DLL with two exported functions:

   library MinMax;

   {The export procedure directive prepares Min and Max for exporting}

   function Min(X, Y: Integer): Integer; export;
     if X < Y then Min := X else Min := Y;

   function Max(X, Y: Integer): Integer; export;
     if X > Y then Max := X else Max := Y;

   {The exports clause actually exports the two routines, supplying an
    optional ordinal number for each of them}

     Min index 1,
     Max index 2;


Libraries often consist of several units. In such cases, the library source file itself is frequently reduced to a uses clause, an exports clause, and the library's initialization code.

For example:

   library Editors;

   uses EdInit, EdInOut, EdFormat, EdPrint;

     InitEditors index 1,
     DoneEditors index 2,
     InsertText index 3,
     DeleteSelection index 4,
     FormatSelection index 5,
     PrintSelection index 6,
     SetErrorHandler index 53;


See Also

 К началу страницы 
Тэги: Library-header DLLs

Код для вставки: :: :: :: ГОСТ ::
Поделиться: //

Хостинг предоставлен компанией "Веб Сервис Центр" при поддержке компании "ДокЛаб"