Adding Your Own External DLL
It is possible to use external library files (DLLs) in your AMT application. Place these files in the call directory specified in Basepaths.
To call these DLL files, use the CALL instruction and the system parameter SI-PARAM to retrieve the DLL result.
By default, the library is called with the same .NET version that runs AMT. To call the library with an older .NET
version, add the library to Sys.ini parameter AMTCALLDLLNET48 or AMTCALLDLL. See Configuring Sys.ini.
The type definitions needed in the DLL are language dependent. In the examples below, you can see that where the Delphi DLL uses the type definition "PChar", the C DLL uses the type "LPSTR". The same type may be called "PAnsiChar" in another language. The Short type that is specified in both examples stands for -32768..32767 signed 16-bit. In other languages this type may be called "Smallint".
Example for calling your external DLL in AMT
Delphi and C
To call the external function that is implemented in the external file "CallTest.dll" in Delphi or C, you can write the following lines:
si-param := 'This is input for the DLL.'
call ('CALLHELLO', 'CallTest.dll')
if getlastresult = ''
sme ('result: ', si-param)
else
sme ('Error in dll CallTest!')
endifC# (.NET)
When calling a .NET DLL created in C#, it is important that the ClassName is also specified in the call as shown in the example.
si-param := 'This is input for the DLL.'
call ('TestCall.CallHello', 'CallTest.dll')
if getlastresult = ''
sme ('result: ', si-param)
else
sme ('Error in dll CallTest!')
endifBelow are examples of writing such a DLL file in Delphi, C, and C#.
Example for writing your DLL in DELPHI
library CallTest;
uses
windows,
SysUtils;
{$R *.res}
Procedure CALLHELLO(glbParam: Pchar; size: Short); StdCall; export;
begin
strcopy(glbparam, 'Hello, This is a test of a Call in AMT.');
end;
Exports CALLHELLO;
begin
IsMultiThread := true;
end.Example for writing your DLL in C
#include <windows.h>
#include <string.h>
#include <stdio.h>
#include <direct.h>
void WINAPI CALLHELLO (LPSTR lpParam, short ParamSize)
{
strcopy( lpParam, "Hello, This is a test of a Call in AMT.");
}Example for writing your DLL in C# (.NET)
namespace CallTest
{
public class TestCall
{
public static String CallHello (String input)
{
return "Hello, This is a test of a Call in AMT." + input;
}
}
}