Jest taki problem :
biblioteka.dll:
(...)
procedure info(var p : PChar) ; stdcall;
var s : string ;
begin
s := 'Program służy do asfasfa f asf f sa ble ble ble...' ;
s := s + #13#10'asfasfasf sf ble ble ble...' ;
p := PChar(s)
end;
(...)
exports
info name 'info' ;
program:
(...)
var p : PChar ;
dll : THandle ;
proc : procedure(pch : pchar) ; stdcall ;
begin
DLL := LoadLibrary('biblioteka.dll');
try
@proc := GetProcAddress(DLL, 'About');
if @proc = nil then raise Exception.Create('Nie można załadować procedury');
proc(p);
application.MessageBox(p,'',mb_ok) ;
finally
FreeLibrary(DLL);
end;
end;
i na MessageBoxie się wywala. (EAccessViolation)
poprawiłem:
procedure info(var p : PChar) ; stdcall;
var s : string ;
begin
s := 'Program służy do asfasfa f asf f sa ble ble ble...' ;
s := s + #13#10'asfasfasf sf ble ble ble...' ;
GetMem(p, Length(s)) ;// <---
p := PChar(s)
end;
ale do pchara dodaje na końcu znak `
co jest źle?
ps. podczas kończenia pracy programu z wykorzystaniem dll też się wywala (EAccessViolation).