Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > Apps

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 04-06-2010, 11:33 AM
joejoe79sa joejoe79sa is offline
Junior Member
 
Join Date: May 2008
Posts: 5
Default dll load and unload

Hi all

I have a problem loading dll more than once. i have 2 functions (just the raw idea of it below )

function LoadDLL(DLL_FileName: string): Boolean;
begin
Result := FALSE;
DLLHandle := LoadLibrary(PChar(DLL_FileName)) ;
Result := true;
end;
--------------
and

function UnloadDLL: Boolean;
begin

Result := FALSE;
if DLLHandle <> 0 then
begin
FreeLibrary(DLLHandle);
end;

Result := TRUE;

end;

some reports are dll's so i just call the dll to do a report. so i call a dll as follow

LoadDLL(ExtractFilePath(Application.ExeName) + '\Reports\Client.dll');

this works fine for this report but as soon as i try to run the next dll report for instance

UnloadDLL;
LoadDLL(ExtractFilePath(Application.ExeName) + '\Reports\Accounts.dll');

the application terminates. If i dont run the unloaddll function then i can open the next report but not the same one i allready opened before.

Any ideas?
Reply With Quote
  #2  
Old 04-06-2010, 12:09 PM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,329
Default

You're using 1 global variable to store the id of multiple dll's... This cannot be done this way, either store them in a list or just use them as local variables...
Furthermore, you validate if the dll is loaded in the unloadDll, but not in the loadDll...
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:16 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.