Start Delphi, then start a new project.
Choose File/Remove File. Remove Form1 from the list. Don't save the changes.
Add a new unit. This unit will contain all the code in the UCD. We will come back to this later.
Next, we set up the code to make this a dll instead of an exe. Choose View/Units. Select Project1.
The top line of code should read program Project1;. To make Delphi create a dll, the 'program' keyword must be changed to 'library'. Do that now.
In the 'uses' section, delete the reference to 'Forms'. If you leave this in, then the resulting dll will be about 150k bigger than it needs to be. Of course, if you are going to use a form in your dll (which is perfectable acceptable), then leave the 'Forms' in.
After the 'uses' section, you need to declare all the functions you are going to make available to APW. For this exercise, add the following line; we will add the UCase function later.
exports Add;
The final thing you have to do to make the dll is to remove the 'Application.Run' line. Since we are not making an exe, we can't actually run the program.
The final code should look like this:
library Project1;
uses Unit1 in 'UNIT1.PAS';
exports Add;
{$R *.RES}
begin
end.
Now you can save the project. The name you give the project will be the name given to the dll created. For the purpose of this exercise, I will assume you call it dlldemo. Save the Unit1 unit as Unit1.pas.
on to: Creating the Add function.
back to: Start