
| Subject: | DLL problem - GetProcAddress error |
| Posted by: | Pak Tse |
| Date: | Sun, 28 Sep 2008 |
Hi,
I use the code below to load a dll but it failed intermittently (sometimes it worked and sometimes it did not), I tested in my local machine and it has no problem at all every time I tested it, however, one of the testing clients got it failed:
procedure TDataModule1.GenerateReport(ReportID: String; aPeriodEndDate: TDateTime);
var
HINST : longint;
dllProc : procFuncRunAutoReport;
begin
try
HINST := LoadLibrary(pchar(IncludeTrailingBackslash(ExtractFilePath(Application.ExeName)) + ReportID + '.dll'));
except
HINST := -1;
end;
if HINST <> -1 then
begin
try
try
dllProc := procFuncRunAutoReport(GetProcAddress(HINST, 'funcRun'));
dllProc(ConnectionComp, Application.Handle, ScheduleID, fLogFileName, aPeriodEndDate);
except on e: exception do
WriteLog('dllProc exception: ' + e.message, fLogFileName);
end;
......
......
The exception occurred and wrote to the log file with the following:
"dllProc exception: Access violation at address 019C6F08 in module '0603.dll'. Read of address 0000000C"
At the moment I am not sure it happened at
dllProc := procFuncRunAutoReport(GetProcAddress(HINST, 'funcRunAutoReport'));
OR
dllProc(ConnectionComp, Application.Handle, ScheduleID, fLogFileName, aPeriodEndDate);
Any idea?
Will it because the client is running that '.dll' at the same time?