Search code examples
delphidelphi-7

please give me the difference in using export and stdcall keywords for exporting the functions in Dll using delphi7


uses
  SysUtils,
  Classes;

{$R *.res}
function add(Value1:integer;value2:integer):integer;stdcall;
begin
  Result:=Value1+value2;
end;

function subtract(Value1:integer;value2:integer):integer;stdcall;
begin
  Result:=Value2-value1;
end;

function multiply(Value1:integer;value2:integer):integer;stdcall;
begin
  Result:=Value1*value2;
end;

function divide(Value1:integer;value2:integer):integer;stdcall;
begin
  Result:=Value2 div value1;
end;

function check(Value1:integer;value2:integer):Boolean;stdcall;
begin
  if(Value2>value1)then
    Result:=True
  else
    Result:=False;
end;

exports add,subtract,multiply,divide,check;

this is my dll code. even if i give export it works. may i know the difference between the usage of these two keywords.


Solution

  • The export keyword is a legacy from 16 bit versions. It is ignored in modern versions of Delphi. Do not confuse it with the exports directive which is used to specify which functions are exported from a library, and which you use correctly in the code presented.

    It doesn't make much sense to compare export with stdcall, a calling convention directive, since they are not directly comparable.