unit Unit6;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, Windows, TimeCodeLib;
Function Ts_CreateGrid (Filename :
String; language : Integer): Integer;
Function Ts_CloseWindow : Integer;
//##############################################################################
implementation
type
TDLL_CreateGrid =
Function(
const Filename :
String; language : Integer): Integer;
cdecl;
TDLL_CloseWindow =
Function : Integer;
cdecl;
var
LibHandle: THandle;
// Handle to the currently loaded dll
myDLL_CreateGrid : TDLL_CreateGrid;
myDLL_CloseWindow : TDLL_CloseWindow;
const
dllName = '
Test.dll';
type
EDLLError =
class(
Exception);
(*******************************************************************************
*******************************************************************************)
Function Ts_CloseWindow: Integer;
Begin
if Assigned(myDLL_CloseWindow)
then begin
Result := myDLL_CloseWindow;
End Else Begin
Result := 0;
End;
End;
(*******************************************************************************
*******************************************************************************)
Function Ts_CreateGrid (Filename :
String; language : Integer): Integer;
Begin
if Assigned(myDLL_CreateGrid)
then begin
Result := myDLL_CreateGrid(Filename, language);
End Else Begin
Result := 0;
End;
End;
(*******************************************************************************
*******************************************************************************)
Procedure ActivateDLL;
Begin
myDLL_CreateGrid :=
NIL;
myDLL_CloseWindow :=
NIL;
Try
LibHandle := LoadLibrary(dllName);
If (LibHandle < 32)
Then Begin
raise EDLLError.Create('
Unable to load '+dllName);
End;
If LibHandle >= 32
Then Begin
myDLL_CreateGrid := GetProcAddress(LibHandle, '
CreateGrid');
myDLL_CloseWindow := GetProcAddress(LibHandle, '
CloseMainWindow');
End;
Except
//
End;
End;
//------------------------------------------------------------------------------
initialization
ActivateDLL;
finalization
Try
FreeLibrary(LibHandle);
Except
End;
end.