Thursday, 13 May 2010

Using DLL file in Delphi

After we created a DLL file in the previous tutorial, now we’re going to use this DLL file in an application. First, you have to create a user interface like picture below :

Or you can download this project here.

Before you write some codes in this project, you have to make sure that the DLL file you’re going to use and your project are in the same directory (folder). Or you can put the DLL file you’re going to use in directory : c:\windows\system.

To use functions in a DLL file we’ve created, you must type the function after {$R *.DFM}

{$R *.DFM}
{ place functions from DLL here }
function area(length, width : integer): integer; stdcall; external 'area_volume.dll';
function volume(length, width, height : integer): integer; stdcall; external 'area_volume.dll';

external clause means that the functions we use (area and volume) are in an external file (area_volume.dll)

To call area function and volume function see the codes below :

procedure TForm1.CalculateAreaButtonClick(Sender: TObject);
  L, W : integer;
  L := StrToInt(Edit1.Text);
  W := StrToInt(Edit2.Text);
  Label8.Caption := Label8.Caption + ' ' + IntToStr(area(L,W));

procedure TForm1.CalculateVolumeButtonClick(Sender: TObject);
  L, W, H : integer;
  L := StrToInt(Edit3.Text);
  W := StrToInt(Edit4.Text);
  H := StrToInt(Edit5.Text);
  Label9.Caption := Label9.Caption + ' ' + IntToStr(volume(L,W,H));

area(L,W) and volume(L,W,H) will return integer type values, so if you want to put these values into label.caption, you have to convert them into string using IntToStr() procedure.

You can download the complete code here.


  1. Ijin download kode lengkapnya ya.
    TFS`frenz :)

  2. mantap langsung download
    salam kenal sob
    moga sukses

  3. @ Aryadevi, kakara, imtikham : thank you very much for dropping by...

  4. panjang banget mas tutorialnya...
    tapi makasih bangyak infonya...

  5. Thank you very much for you can share your post,the article content written very well,extremely is worth my study.

  6. if you don not have your Cadfile finished we can assist you with creating 3dcadfiles which are necessity to program our sophisticated machinery.

    usually we do our best to make a quotation within 2-4 days.


These links are part of a pay per click advertising program called Infolinks. Infolinks is an In Text advertising service; they take my text and create links within it. If you hover your mouse over these double underlined links, you will see a small dialog box containing an advertisement related to the text. You can choose to move the mouse away and go on with your browsing, or to click on the box and visit the relevant ad. Click here to learn more about Infolinks Double Underline Link Ads.