mam pytanie jak skorzystać z funkcji z dll?
zrobiłem sobie taki teścik:
...
type
my = function (s : integer) : string;
...
procedure TForm1.Button1Click(Sender: TObject);
var
DLL : THandle;
test : my;
begin
DLL := LoadLibrary('win.dll');
try
@test := GetProcAddress(DLL, 'Podwojenie');
if @test=nil then raise Exception.Create('Bład - nie mogę znaleźć funkcji w bibliotece!');
ShowMessage(test(4));
finally
FreeLibrary(DLL);
end;
end;
end.
i kod biblioteczki
library Project1;
uses Windows,SysUtils;
function Podwojenie(var a : integer) : string; stdcall;
begin
a := a * 2;
Result := IntToStr(a);
end;
exports
Podwojenie name 'Podwojenie';
begin
end.
i wywaliło mi bład "Access violation at address ..."
wie ktoś jak powino być poprawnie?