Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

FreeLibrary in ActiveForm

Posted on 2002-05-14
4
Medium Priority
?
735 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 840 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

885 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