Solved

FreeLibrary in ActiveForm

Posted on 2002-05-14
4
722 Views
Last Modified: 2007-11-27
Hi all,

I've developed a ActiveX control (TActiveForm) in Delphi 5 to be used only in Internet Explorer 5+ (HTML page).

In this OCX I have to dynamically load and unload a DLL, let's say MYDLL.DLL.

Firstly, I tried to place LoadLibrary in TMyFormX.Initialize, but I couldn't guess the right place to call FreeLibrary.

I now have LoadLibrary in TMyFormX.ActiveFormCreate and FreeLibrary goes into TMyFormX.ActiveFormDestroy

Using breakpoints I can see that FormCreate and Initialize are called many, many times, for example, HTML page reload, but I never could trace FormDestroy.

As I'm having some GPF's in I.E. and details tells me IEXPLORE bla bla bla (you know what I mean..) in MYDLL.DLL I'm very suspicious that LoadLibrary & FreeLibrary are not in right place.

The question:

In which events handlers I must place LoadLibrary & FreeLibrary stuff in my ActiveForm control???

Many thanks in advance,
Itamar
0
Comment
Question by:itamar
  • 2
4 Comments
 
LVL 17

Accepted Solution

by:
inthe earned 210 total points
ID: 7010132
i would only use dll's for holding functions/routines that wanted to be kept seperate from main program for upgrading purposes or good housekeeping etc.. try to load and unload the dll when its needed instead of leaving it loaded.
for example if you have a function that uses it then load for the function then free it.
the reasons here are activex's dont get notified of the form destroy events etc..so it would be difficult to say when would be best to free it.
0
 
LVL 4

Author Comment

by:itamar
ID: 7010160
Hi inthe,

bad news for me!

I have some good reasons to call external DLL's.
The load and unload in each function call probably will causes me performance problems, but I'll try anyway...

Really disapointed with ActiveX...
If TActiveForm has a initialize method that can be overridden, it should also have a finalize one!

Well, perhaps someone else can bring some other ideas to this thread, but if you are saying so, I'm not so hopefulness ;-)

Thanks a lot!
Itamar
0
 
LVL 9

Expert Comment

by:ITugay
ID: 7010491
Hi itamar,

not sure for ActiveX, but usually you can do it something like this:

unit SomeUnit;
...
interface
...
implementaion
...
initialization
  // load library here
finalization
  // unload library here
end.

0
 
LVL 4

Author Comment

by:itamar
ID: 7057991
Hi inthe,

your comment was the more usefull.

Thanks,
Itamar
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now