Adding Your Own External DLL
It is possible to use external library files (dlls) in your AMT application. These external library files should be placed in the call directory specified in your Basepaths.
To call these dll files, you can write a CALL instruction and use the system parameter SI-PARAM to request the result that is generated by the external dll file.
By default the library will be called by the same .NET version which runs AMT. To call the library with an older .NET version, the library must be added to either the Sys.ini parameter 'AMTCALLDLLNET48' or 'AMTCALLDLL'. See Configuring Sys.ini.
The type definitions that are needed in the dll are language dependant. In the examples below, you can see that where in the Delphi dll the type definition "PChar" is used, 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:
call ('CALLHELLO', 'CallTest.dll')
if getlastresult = ''
sme ('result: ', si-param)
else
sme ('Error in dll CallTest!')
endif
C# (.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.
call ('TestCall.CallHello', 'CallTest.dll')
if getlastresult = ''
sme ('result: ', si-param)
else
sme ('Error in dll CallTest!')
endif
Below, you can find examples on writing such a DLL-file in DELPHI or in C and C#.
Example for writing your DLL in DELPHI
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 <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)
public class TestCall {
public static String CallHello (String input) {
return "Hello, This is a test of a Call in AMT." + input;
}
}
}