Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Units to DLLs

Status
Not open for further replies.

DjangMan

Programmer
Jun 1, 2001
1,783
CA
I saw in a previous related post that some develpers convert their units to DLLs once they are finished developing.

My question is, is what's involved? Can I use conditional defines to make and use DLLs or Units at my leisure?

DjangMan
 
--------------------------------------------
Here is how I convert my units to DLL’s
--------------------------------------------
Unit RsrFMgmt;
Interface
uses
ShareMem,
SysUtils;

function Func1(Var p1,p2,p3 : String) : Boolean;
function Func2(a,b : Integer; Var c,d : Integer) : boolean;

Implementation

function Func1(Var p1,p2,p3 : String) : Boolean;
begin
.
.
.
end;

function Func2(a,b : Integer; Var c,d : Integer) : boolean;
begin
.
.
.
end;

end.

-------------------------------------------------------------------
Converting the above unit to a DLL is as follows:
-------------------------------------------------------------------

library RsrFMgmt;
uses
ShareMem,
SysUtils;

function Func1(Var p1,p2,p3 : String) : Boolean; Export;
begin
.
.
.
end;

function Func2(a,b : Integer; Var c,d : Integer) : boolean; Export;
begin
.
.
.
end;

Exports Func1 Index 1,
Func2 Index 2;

begin
end.

---------------------------------------------
Store your compiled DLL in the
Windows system directory.

A new unit needs to be written to access your DLL’s within your program.
---------------------------------------------
Unit UsingDLLs;
Interface
uses
ShareMem,
SysUtils;


function Func1(Var p1,p2,p3 : String) : Boolean;
function Func2(a,b : Integer; Var c,d : Integer) : boolean;

Implementation

function Func1(Var p1,p2,p3 : string) : boolean; External 'RsrFMgmt' Index 1;
function Func2(a,b : integer; var c,d : integer) : boolean; External 'RsrFMgmt' Index 2;
end.

---------------------------------------------------------------
Hope this helps. Good luck!
---------------------------------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top