Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

FreeLibrary in ActiveForm

Posted on 2002-05-14
4
Medium Priority
?
734 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

705 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