unit uMathLibrary;

interface

uses
  Windows;

function ScottAddDoubles(a: double; b: double): double; stdCall;
function AddDouble(a: double; b: double): double; stdCall;

function AddInt(a: integer; b: integer): integer; stdCall;
function ANDER(a: boolean; b: boolean): boolean; stdCall;

function AddMultiply(a: double; b: double): double;
function Multiply(a: double; b: double): double;
procedure ReturnTwoStrings(Str1, Str2: pAnsichar); stdCall;
// function Version(Str1: pAnsichar): integer; stdCall;

implementation

var
  dllHandle: cardinal;

  // function Version; external 'MathLibrary.dll' index 8;

function ScottAddDoubles(a: double; b: double): double; stdCall;
type
  TScottAddDoublesFunc = function(aa: double; bb: double): double; stdCall;
var
  ScottAddDoublesFunc: TScottAddDoublesFunc;
  res: double;
begin
  dllHandle := LoadLibrary('MathLibrary.dll');
  if dllHandle <> 0 then
  begin
    @ScottAddDoublesFunc := GetProcAddress(dllHandle, 'ScottAddDoubles');
    if Assigned(ScottAddDoublesFunc) then
      result := ScottAddDoublesFunc(a, b)

    else
    begin
      resutl := 666;
      FreeLibrary(dllHandle);
    end;
  end;
end;

// function ScottAddDoubles; external 'MathLibrary.dll' index 5;
function AddDouble; external 'MathLibrary.dll' index 2;
function AddInt; external 'MathLibrary.dll' index 3;
function ANDER; external 'MathLibrary.dll' index 1;

function AddMultiply; external 'MathLibrary.dll' index 4;
function Multiply; external 'MathLibrary.dll' index 5;

procedure ReturnTwoStrings; external 'MathLibrary.dll' index 6;

end.
