Hallo,
ich habe zwei Pascal-Quellen, und ich möchte eine Callback-Funktion schreiben, aber ich scheitere daran:
Delphi-Quellcode:
unit misc;
interface
uses Windows, SysUtils;
type
TMainCallback =
procedure of object;
function InitLibrary(Callback: TMainCallback): Boolean;
implementation
uses fpcmain;
function ErrorMessage(s: AnsiString): Boolean;
cdecl;
external dllname;
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;
finally
FreeLibrary(DLLHandle);
ReadLn;
ExitProcess(0);
end;
end;
end.
Delphi-Quellcode:
{$APPTYPE CONSOLE}
program fpcqt;
uses
Windows,
QCharClass,
fpcmain in 'fpcmain.pas',
misc in 'misc.pas';
var
Callback: TMainCallback;
procedure EntryPoint;
var
myQChar: QChar;
begin
myQChar := QChar.Create;
if myQChar.isDigit then
WriteLn('ok') else
WriteLn('not ok');
Readln;
myQChar.Free;
end;
begin
Callback := EntryPoint;
InitLibrary(Callback);
end.