ich habe eine InitLibrary Funktion, in der der Callback in ein try except Block eingebettet ist:
Delphi-Quellcode:
{$ifdef FPC}
{$mode delphi}{$H+}
{$else}
{$APPTYPE CONSOLE}
{$endif}
program fpcqt;
uses
{$ifdef win64}
Windows,
{$endif }
appsettings
in '
pas\appsettings.pas',
misc
in '
pas\misc.pas',
fpcmain
in '
pas\fpcmain.pas',
QCharClass
in '
pas\QCharClass.pas';
procedure EntryPoint(argc: Integer; argv:
Array of String);
var
myQChar: QChar;
begin
myQChar := QChar.Create;
if myQChar.isDigit
then
WriteLn('
ok')
else
WriteLn('
not ok');
Readln;
myQChar.Free;
end;
begin
InitLibrary( EntryPoint );
end.
Delphi-Quellcode:
{$ifdef FPC}
{$mode delphi}{$H+}
{$endif}
unit misc;
interface
uses
{$ifdef win64}
Windows,
{$endif}
SysUtils;
const DLLname = '
fpc-qt.dll';
type
TMainCallback =
procedure(argc: Integer; argv:
Array of String);
function InitLibrary(Callback: TMainCallback): Boolean;
function ErrorMessage(s: AnsiString): Boolean;
cdecl;
external dllname;
implementation
uses fpcmain;
function InitLibrary(Callback: TMainCallback): Boolean;
begin
DLLHandle := LoadLibrary('
fpc-qt.dll');
if DLLHandle = 0
then
begin
ErrorMessage('
Error: DLL could not be loaded.');
Halt(1);
end;
try
Callback(ParamCount, ParamStr(1));
finally
FreeLibrary(DLLHandle);
ReadLn;
Halt(0);
end;
end;
end.