Mam taki plik Quotations.dll:
library Quotations;
uses
ShareMem, Windows, Messages;
{$R *.res}
const
WM_PROCESSEND = WM_USER + 1100;
AQuotations: array[1..65] of ShortString =
( {Tutaj cytaty} )
function SelectQuote(i: Integer): ShortString; stdcall;
begin
Randomize;
while i = 0 do
i:= Random(65);
Result:= AQuotations[i];
end;
procedure DLL_Proc(Reason : Integer);
begin
if Reason = DLL_PROCESS_DETACH then
SendMessage(FindWindow('TMainForm', nil), WM_PROCESSEND, 0, 0);
end;
exports
SelectQuote name 'SelectQuote';
begin
DLLProc := @DLL_Proc;
end.
i w programie dwie procedury:
const WM_PROCESSEND = WM_USER + 1100;
private
{ Private declarations }
procedure WMProcessEnd(var Msg : TMessage); message WM_PROCESSEND;
procedure Quotations_DLL;
procedure TAktualizuj.WMProcessEnd(var Msg : TMessage);
begin
MainForm.Quote.Caption:= 'Cytat dnia: ' + Quote;
end;
procedure TAktualizuj.Quotations_DLL;
var DLL: THandle;
SelectQuote: function(i: Integer): ShortString;
begin
DLL := LoadLibrary('Quotations.dll');
try
@SelectQuote:= GetProcAddress(DLL, 'SelectQuote');
if @SelectQuote = nil then
raise Exception.Create('Nie można wczytać cytatów!');
Quote:= SelectQuote(0);
finally
FreeLibrary(DLL);
end;
end;
i gdzieś w dalszym kodzie ;p
Quotations_DLL;
Po wykonaniu przez program procedury Quotations_DLL; wyświetla się błąd Debugger Fault Notification:
Project ..\Project1.exe raised too many consecutive exceptions: 'access violation at 0x00000000: read of address 0x00000000'. Process Stopped. Use Step or Run to continue.
i okno CPU, w którym:
00000000 ????
00000001 ????
itd.
Proszę o pomoc w naprawieniu błędu/ów, które to powodują.