unit DllInterface;

interface

uses GPSforWindows_Types;

type
  TDll_sensorCount                = function:longint; stdcall;
  TDll_sensorInformation          = function(index: longint): TSensorInformation; stdcall;
  TDll_locationInformation        = function:TLocationInformation; stdcall;
  TDll_lightInformation           = function:TLightInformation; stdcall;
  TDll_orientationInformation     = function:TOrientationInformation; stdcall;
  TDll_environmentalInformation   = function:TEnvironmentalInformation; stdcall;
  TDll_motionInformation          = function:TMotionInformation; stdcall;
  TDll_electricalInformation      = function:TElectricalInformation; stdcall;
  TDll_mechanicalInformation      = function:TMechanicalInformation; stdcall;
  TDll_biometricInformation       = function:TBiometricInformation; stdcall;
  TDll_scannerInformation         = function:TScannerInformation; stdcall;

var
  hDll                            : THandle;
  Dll_sensorCount                 : TDll_sensorCount;
  Dll_sensorInformation           : TDll_sensorInformation;
  Dll_locationInformation         : TDll_locationInformation;
  Dll_lightInformation            : TDll_lightInformation;
  Dll_orientationInformation      : TDll_orientationInformation;
  Dll_environmentalInformation    : TDll_environmentalInformation;
  Dll_motionInformation           : TDll_motionInformation;
  Dll_electricalInformation       : TDll_electricalInformation;
  Dll_mechanicalInformation       : TDll_mechanicalInformation;
  Dll_biometricInformation        : TDll_biometricInformation;
  Dll_scannerInformation          : TDll_scannerInformation;

function deInitDll: boolean;
function initDll(dllname: string): boolean;

implementation

uses windows;

function initDll(dllname: string): boolean;
begin
  hDll := loadlibrary (PWideChar(dllname));
  if hDll <> 0 then begin
    @Dll_sensorCount              := GetProcAddress(hDll, 'sensorCount');
    @Dll_sensorInformation        := GetProcAddress(hDll, 'sensorInformation');
    @Dll_locationInformation      := GetProcAddress(hDll, 'locationInformation');
    @Dll_lightInformation         := GetProcAddress(hDll, 'lightInformation');
    @Dll_orientationInformation   := GetProcAddress(hDll, 'orientationInformation');
    @Dll_environmentalInformation := GetProcAddress(hDll, 'environmentalInformation');
    @Dll_motionInformation        := GetProcAddress(hDll, 'motionInformation');
    @Dll_electricalInformation    := GetProcAddress(hDll, 'electricalInformation');
    @Dll_mechanicalInformation    := GetProcAddress(hDll, 'mechanicalInformation');
    @Dll_biometricInformation     := GetProcAddress(hDll, 'biometricInformation');
    @Dll_scannerInformation       := GetProcAddress(hDll, 'scannerInformation');
  end;
  result := hdll <> 0;
end;

function deInitDll: boolean;
begin
  if hDll <> 0 then begin
    FreeLibrary(hDll);
    hDll := 0;
  end;
  result := TRUE;
end;

initialization
  hDll := 0;

end.
