Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2008 May : LoadLibrary exception

www.cryer.info
Managed Newsgroup Archive

LoadLibrary exception

Subject:LoadLibrary exception
Posted by:"AlanT" (alanpltse_nospam@yahoo.com.au)
Date:Mon, 12 May 2008 12:43:04 +1000

D5, Windows XP SP2.

Hi, this is my source code:

procedure TForm1.Button1Click(Sender : TObject);
var
  HINST : longint;
  FarPointer : TFarProc;
  proc : procFuncRunReport;
  lastError : dword;
  MesStr : string;
  tempInt: longbool;
begin
  try
    HINST := LoadLibrary(pchar(FdllFilename));
  except
    HINST := -1;
  end;
  if HINSt <> -1 then
  begin
    FarPointer := GetProcAddress(HINST, 'myTestDLLProcedure');
    if FarPointer <> nil then
    try
      ......
    finally
      FreeLibrary(HINST);
    end
    else
    begin
      .......
  end;

When I first click the button, it loads the DLL and pop up the form (this
form within the DLL), it is loaded sucessfully.
Then when I click the button again, I got a exception about the "
The instruction at "0x00000000" referenced memory at "0x00000000". The
memory could not be "read".

Any hints.

Glossary

Replies:

www.cryer.info
Managed Newsgroup Archive